|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-03-25 00:00 UTC] ryan at daelibs dot com dot au
Description:
------------
When you use a session name that has only numbers, each call to session_start seems to regenerate a new session id, so the session does not persist.
The code below can be loaded and refreshed to reproduce the behaviour
Reproduce code:
---------------
<?php
//This name works
//session_name('A9');
//This name doesn't
session_name('99');
session_start();
echo 'Session Name: '.session_name().'<br />';
echo 'Session Id: '.session_id().'<br />';
?>
Expected result:
----------------
Session Name: 99
Session Id: {{a sid that remains the same between each refresh }}
Actual result:
--------------
Session Name: 99
Session Id: {{a different sid each refresh}}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 11:00:02 2025 UTC |
Here's a simple workaround: <?php // This name works. //session_name('A9'); // This name doesn't... session_name('99'); // Force the last session id, not the detected one. session_id($_COOKIE[session_name()]); session_start(); echo ' Session Name: ', session_name(), '<br /> Session ID: ', session_id(), '<br /> Cookie: ', $_COOKIE[session_name()]; ?> Removing the session_id() line though, shows that the cookie is still being properly set. -[Unknown]