homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Should all my pages have session start(); ?

 5:30 pm on May 3, 2012 (gmt 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


DarkEden Genesis

 5:31 pm on May 3, 2012 (gmt 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)

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)

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)

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)

@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.



 6:21 pm on May 5, 2012 (gmt 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.


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved