php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32966 Problem parsing cookies
Submitted: 2005-05-06 17:52 UTC Modified: 2005-05-06 22:58 UTC
From: m dot cave-ayland at webbased dot co dot uk Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.11 OS: Linux 2.4
Private report: No CVE-ID: None
 [2005-05-06 17:52 UTC] m dot cave-ayland at webbased dot co dot uk
Description:
------------
I have found a problem with using sessions and cookies under PHP 4.3.3, however I have done a brief check using the CVS web interface and I believe the problem may still be present in the latest 4.3.11. A test with PHP 5.0 showed the problem did not exist there.

I was using a buggy client that was accidently sending two "Cookie:" strings containing the PHP session ID to the webserver (Apache 2.0.47) during a form POST to upload a file, and found that PHP was erroring out with the error "The session id contains invalid characters, valid characters are only a-z, A-Z and 0-9". The error disappeared when the Cookie line was sent once as expected.

Digging into the code shows that cookie values retrieved from the SAPI manager were being separated by a comma, whereas the PHP code was looking for a semi-colon and null as separator values.

My fix was to add a comma to the list of separators at the equivalent of line 293 of /main/php_variables.c in PHP 4.3.11, however this is my first look at the PHP source and so there may be a better fix or this may not be correct.


Many thanks,

Mark.


Reproduce code:
---------------
Using a raw telnet session to an Apache WebServer running PHP:

GET / HTTP/1.0
Host: myhost.somewhere.com
Cookie: PHPSESSID=6664337de02c5bad6c175e0bb3c10a45
Cookie: PHPSESSID=6664337de02c5bad6c175e0bb3c10a45
Cookie: ANOTHER=randomvalue

Expected result:
----------------
No error.

Actual result:
--------------
session_start(): The session id contains invalid characters, valid characters are only a-z, A-Z and 0-9

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-06 22:58 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #32111

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 03 13:01:33 2025 UTC