session variables

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
frosty16
Forum Newbie
Posts: 19
Joined: Sat Jan 26, 2008 6:58 am

session variables

Post 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
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: session variables

Post by Zoxive »

Is session_start() on the top of every page you are trying to access the session variables?
frosty16
Forum Newbie
Posts: 19
Joined: Sat Jan 26, 2008 6:58 am

Re: session variables

Post by frosty16 »

no the session_start() is only on the top of the first page i.e. the login page
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: session variables

Post 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.
frosty16
Forum Newbie
Posts: 19
Joined: Sat Jan 26, 2008 6:58 am

Re: session variables

Post by frosty16 »

o brilliant thank you
Post Reply