I have the following source code
session1.php
<?php session_start(); echo session_id(); ?>
session2.php
<?php session_start(); echo session_id(); ?>
when I access session1.php then access session2.php, I get a different ouput.
Why is this doing it?
Advertisement
Answer
The browser is not sending the session cookie back to the server. This can have two reasons.
- The browser is configured not to send cookies to the server. You cannot force the browser to send cookies. In this case your only option is to pass the session identifier in the URL, although this is generally not a good idea.
- The server is configured not to use cookies for the session identifier (by means of the session.use_cookies configuration option).