Possible Duplicate:
Where are $_SESSION variables stored?
When ever we working with session, we need to start the session in each page. now suppose i have set the session in 1.php now redirecting to 2.php, in 2.php page i am starting the session again there is no any link between 1.php and 2.php. 2.php is not knowing what is the session id of 1.php.
Now my question is How this 2.php is getting the same session id started by 1.php. Where this session is stored? how it is working?
Here we are not passing any parameter from 1.php to 2.php, as Frederick Marcoux is saying SESSION_START() is IGNORED by 2.php. So how 2.php will get to know that session is already running.
if it is on server side,then in case of multiple session then how will it identify which session is for which request?
Think of it this way….
When someone accesses your 1.php page, the session_start() on the top of the page initiates an action on your server (hosting) and unique session id is generated.
Then it is attached to every page (url) on your server (under the same domain) (i.e.: 2.php or 3.php) and if these pages have the session_start() function present, the SID is available for the scripts (on those pages) and can be accessed and verified.
If the SID on your page 3.php is matching the one created/generated by the same user when he/she accessed the page 1.php then you know that this page is being accessed by the same person and do something else for them which you would not do for a visitor who got directly to the page 3.php and did not obtain the necessary SID for example.
The SID is passed from the server to your browser and kept as cookie until it is cleared or it expires.
( …did I diluted it down to much ? 🙂