Reputation: 617
I am stumped. Everybody says if you use session_start that you should get a single session even when you open multiple browser windows. However, it seems that my sessions are page specific.
When I load page one (index.php), it gives as a Session ID: sr51j9hhrjjrvbrfboek15l4e4 with an empty $_SESSION array
I then log in on a webpage (login.php) that generates a new Session ID: v2t8844nglg7uvnsrbr6k9ms43 with a $_SESSION array with various variables.
When I then reload page one, it will display the old session ID, not the new one as expected. It is page linked because if I copy load page two in tab one, it will give the same session ID as the page in tab 2, and visa versa.
I have added the rule
CacheDisable /local_files
to the httpd.conf file with no effect.
I uses Apache 2.4 (XAMPP installation for windows), with the http://php-login.net advanced login script.
Top of page (before the HTML tag):
session_start();
require_once('includes/connection.php');
followed by:
echo var_dump($_SESSION);
echo session_save_path();
echo 'Session ID: '.session_id();
at the top of the page in the body tag. Any suggestions?
Upvotes: 0
Views: 170
Reputation: 617
Okay, found the answer here: My session ID's stopped working
One page was localhost:8001, while the second was 127.0.0.1:8001, which are treated by the server as two separate pages for the purpose of sessions, while serving the same page.
Upvotes: 0
Reputation: 1804
session_start() will create a single session that can be used across the same browser/tabs.
Upvotes: 2