Welcome to WebmasterWorld Guest from 54.234.38.8

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Should all my pages have session start(); ?

     
5:30 pm on May 3, 2012 (gmt 0)

Junior Member

joined:Feb 23, 2012
posts: 91
votes: 0


I appreciate any help and please don't answer with to complicated replies. I'm only a rookie and as you can see this is all I could achieve.

Iím following tutorials online and Iíve notice some scripts have session_start(); and some donít.

Thanks, Scott
5:31 pm on May 3, 2012 (gmt 0)

New User

joined:Jan 4, 2012
posts: 35
votes: 0


I guess it depends on what you are doing.

My website uses session_start(); on the conf.php file, so it "broadcasts" to all pages.
7:04 pm on May 3, 2012 (gmt 0)

Administrator from US 

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
posts:14622
votes: 86


You really don't need sessions per page unless the site requires a login of some other data that much be checked on every page. The session just binds some data on the server with a cookie in the browser and you can skip pages and it'll still reconnect.

conf.php file,


Um, you mention this file a lot, but not everyone has one.

What are you using, Drupal? WordPress?
7:16 pm on May 3, 2012 (gmt 0)

Moderator from CA 

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 29, 2003
posts:4059
votes: 0


you need to call session_start() if your code uses the $_SESSION superglobal variable.

If you don't see $_SESSION used anywhere in the code, then you don't need to call session_start().
12:12 am on May 4, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
posts:7999
votes: 0


The web is a stateless existence. You call a page, the connection between YOU and the server dies.

Sessions are how a web site's pages can stay connected to you (the browser, client) by setting a cookie in the browser and using that cookie to connect to the session files on the server. This is how you stay logged in, this is how you keep track of someone's shopping cart, this is how you maintain state across many page navigations.

Doing anything like that? Sessions=good, use them everywhere (a global include IS a good idea then.)
11:03 am on May 4, 2012 (gmt 0)

Junior Member

joined:Feb 23, 2012
posts: 91
votes: 0


@DarkEdenGenesis Iím building a social network website.

@incrediBILL Im not using Drupal or WordPress.

@httpwebwitch That makes sense. I have a few diff. scripts that have $_SESSION.

@rockabil Thanks again for your expertise clarification.

Thanks to all to responded.

Scotty
6:21 pm on May 5, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2008
posts:138
votes: 0


If your web site is behind a caching server, session_start();
should force a fresh fetch of the page -- if that is important
for that page.

Jonesy