learn

Carry session data from one page to another

category: Ask
Created by: Dr.Ferrous

Carry session data from one page to another

category: Ask
Created by: Dr.Ferrous
twitter google+ facebook pin 

Question:

how to carry session data from one page to another and to other pages as well??

by inam

Answer:

Session variables are not stored in HTML or php files to be passed, they are data stored on the server and are available on any page as long as the session is alive.

Assume you have a page named "index.php" with the following script:

 

And you want to pass the session variable "SiteName" to another page, simple write the following:

 

This will return "phpwin.org".

you must first open index.php to assign the session variable, otherwise anotherpage.php will not echo SiteName because it's not defined.

 

For more information about sessions, please read this lesson Sessions