Forum Moderators: coopster

Message Too Old, No Replies

Session variables

Will they transfer?

         

wkpride

11:04 pm on Mar 11, 2009 (gmt 0)

10+ Year Member



Easy question tonight -

If I declare a session variable on a page and then redirect user to another page (header('Location:http://...)

Do you have to declare the variable again - or does it carry over to the next page?

Thanks,

KP

eelixduppy

12:05 am on Mar 12, 2009 (gmt 0)



If you start the session on the redirected page it should carry over.

GenSwat

1:13 am on Mar 12, 2009 (gmt 0)

10+ Year Member



well I know $foo= regular vars are restricted to page only...
for as a session var i'm unsure

ag_47

1:27 am on Mar 12, 2009 (gmt 0)

10+ Year Member



Isn't that the whole point of sessions...

wkpride

1:45 am on Mar 12, 2009 (gmt 0)

10+ Year Member



Very good.
They do work, when you open a new window. I guess I didn't really know the definition of session.
A session is... until the browser is closed.

Thanks!

KP

blang

3:13 am on Mar 12, 2009 (gmt 0)

10+ Year Member



Everything you ever wanted to know about sessions is in the PHP manual [us2.php.net]. And yes, that's the point of a session, to maintain an active state in a stateless realm (i.e. HTTP). Just remember, every page that needs to access the session data must have a call to session_start() [php.net] at the top of each script!