For Programmers: Free Programming Magazines  


Home > Archive > PHP Documentation > July 2005 > #27688 [Opn->Csd]: Session names consisting of only numbers cause session id gener









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author #27688 [Opn->Csd]: Session names consisting of only numbers cause session id gener
vrana@php.net

2005-07-30, 3:59 am

ID: 27688
Updated by: vrana@php.net
Reported By: ryan at daelibs dot com dot au
-Status: Open
+Status: Closed
Bug Type: Documentation problem
Operating System: *
PHP Version: 5CVS, 4CVS (2005-01-10)
New Comment:

This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation
better.

"Session name can't consist only from digits, at least one letter must
be present. Otherwise new session id is generated every time."


Previous Comments:
------------------------------------------------------------------------

[2005-07-29 18:30:20] sniper@php.net

There should be a big fat warning about this in the manual.


------------------------------------------------------------------------

[2005-07-29 18:29:48] sniper@php.net

Session name can NOT be a plain number.
No checks will be added since that'd make the code slower for no real
gain.


------------------------------------------------------------------------

[2004-03-29 09:39:15] amt@php.net

This happens because PHP turns a numeric session name
into an array index inside $_COOKIE and we're doing an
zend_hash_find() instead of a zend_hash_index_find().
(ext/session/session.c, line 1098).

We can probably fix the bug by doing a
zend_hash_index_find() instead if the session name
successfully converts to a integer.


------------------------------------------------------------------------

[2004-03-29 04:53:03] unknown at simplemachines dot org

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]

------------------------------------------------------------------------

[2004-03-25 00:00:26] 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}}


------------------------------------------------------------------------


--
Edit this bug report at http://bugs.php.net/?id=27688&edit=1
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com