session accessing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
call
Forum Newbie
Posts: 10
Joined: Thu Mar 18, 2004 12:15 am
Location: india

session accessing

Post by call »

I declared session in page with session_start() and defined their variables.
in the subsequent pages I am unable to access that variables unless I declare again as session_start(). Plz help me understanding this.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Penguinboy: if you want to post a link can you do it a little less rudely?

Call: that's the way it works ie you call session_start() in every new script, anywhere you like before any client output.
call
Forum Newbie
Posts: 10
Joined: Thu Mar 18, 2004 12:15 am
Location: india

Post by call »

if I declare session_start() in every page , does it not mean that everytime a new session to start?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

call wrote:if I declare session_start() in every page , does it not mean that everytime a new session to start?
Sessions don't really exist - it just looks like they do.

Session variables are saved in a file after each http request.

On the next http request a session file is opened based on session ID - either sent via GET or stored in a cookie. That's what session_start() does: tells the server to go and unserialise a bunch of vars stored in a particular file (or create a new file if this is the first http request in the session).
Post Reply