Page 1 of 1

session variables

Posted: Tue Jan 29, 2008 10:32 am
by frosty16
heya everyone

I am having a few troubles using the session variable.

On the login page i am starting the session and assigning a value (the username) to the $_SESSION variable.
Then i am tryin to access that variable on the next page and it isnt showing it and the same on a different page. However if i change it so that instead of loading a page is the login details are correct it just display's the username from teh $_Session variable then it displayes it fine.

Can anyone help?

Frosty

Re: session variables

Posted: Tue Jan 29, 2008 10:35 am
by Zoxive
Is session_start() on the top of every page you are trying to access the session variables?

Re: session variables

Posted: Tue Jan 29, 2008 10:41 am
by frosty16
no the session_start() is only on the top of the first page i.e. the login page

Re: session variables

Posted: Tue Jan 29, 2008 10:48 am
by Zoxive
frosty16 wrote:no the session_start() is only on the top of the first page i.e. the login page
You need it on every page that wants to access the sessions.
[url=http://php.net/session_start]PHP Manual - session_start[/url]l wrote:session_start() creates a session or resumes the current one based on the current session id that's being passed via a request, such as GET, POST, or a cookie.

Re: session variables

Posted: Tue Jan 29, 2008 10:57 am
by frosty16
o brilliant thank you