Reputation: 16015
On every page load I see the session cookie's value is changing so it is creating a new session every time. All I'm doing is session_start()
and set some sample test data, without any configuration myself, using default values from php.ini
.
session.save_handler = files
session.save_path = "C:\xampp\tmp"
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
In C:\xampp\tmp
I observe new session files appearing with every page load, and when opened I see that the data I set is inside. So the problem is, I guess, with recognizing previously created session files. Any ideas as to why this is happening?
The data I set is just to see if the session is working
session_start();
if(isset($_SESSION['test'])){
$_SESSION['test']++;
}else{
$_SESSION['test'] = 1;
}
Upvotes: 1
Views: 124
Reputation: 16015
The framework I'm working with has a custom cookie handling mechanism that loads cookies into a static class and empties $_COOKIE
. Apparently session_start()
relies on $_COOKIE
to retrieve the session id by default, so what I had to do is provide the session id from the cookies class
session_id(\Cookie::get('PHPSESSID'));
session_start();
Upvotes: 1