I recently switched over to using our database to manage PHP sessions for our users. The database session handler I've implemented is, for the most part, the same as this one.
That being said, I've run into some weird behavior. On a single page load, the PHP session ID is changing a few different times. For instance, the output below was written to a file during one page load using file_put_contents in my _write
for my session_set_save_handler()
call.
I've searched the code and session_regenerate_id()
is never called nor is session_id(<new_id>)
. Furthermore, my php.ini has session.auto_start set to Off
. Basically, I have no idea how the session ID could change in one page load given the above facts.
The reason I noticed it is because the REPLACE INTO
SQL statement from the linked to webpage is creating 8 or so rows in my database (one for each extra, different session id). As you can see, one of them is repeated for four times or so. That happens to be the only session ID that also has data associated with it when put into the database.
f951tbvjkc8c5mv25aakfhoq86
f951tbvjkc8c5mv25aakfhoq86
f951tbvjkc8c5mv25aakfhoq86
f951tbvjkc8c5mv25aakfhoq86
eodjh2vhuo5ni1b7ia5ro6itf7
bada69955ld96fks0g057pp7i2
4n4c00ddlolb9k2t3uh2h66v37
lsqhhmfsund3bp3ocotcrj0l05
qvfe3qp6nupokcncp8jja8tsk0
4qfp9m3knabs88t6n1fkjo8oq6
g52du9v2fcsak27tjo7519q7j0
It may be worth noting that the page I'm loading has some AJAX requests in it to our own server. Furthermore, this behavior doesn't happen on all page loads on our site. So far I've narrowed it down to this one page that makes a few different AJAX requests.
Thoughts?
UPDATE: I have the following vhost in my server as a wildcard for custom domains. The commented out line was I think what was causing it. When I comment that out, it appears to work fine. With that in there, it appears to cause the weird behavior.
<VirtualHost *:80>
DocumentRoot "/opt/local/www/mysite.com"
ServerName default
ServerAlias *
ErrorLog "/opt/local/apache2/logs/mysite.com-error.log"
CustomLog "/opt/local/apache2/logs/mysite.com-access.log" common
<Directory "/opt/local/www/mysite.com">
AllowOverride All
php_value session.save_path "/opt/local/www/mysite.com/sessions"
#php_value session.cookie_domain "mysite.local"
php_value auto_prepend_file "/opt/local/www/mysite.com/core.php"
</Directory>
</VirtualHost>