3

There is one comma, when tracking the request and var_dump $_SERVER. This caused the web user can not get information by session. Why? How can i sovle it.

[HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
[HTTP_ACCEPT_ENCODING] => gzip,deflate
[HTTP_ACCEPT_LANGUAGE] => zh-CN, en-US
[HTTP_ACCEPT_CHARSET] => utf-8, iso-8859-1, utf-16, *;q=0.7
[HTTP_COOKIE] => , FRONTEND=vkq1nq69lhequ5v1v7kor2sj71
[PATH] => /usr/local/bin:/usr/bin:/bin
light
  • 51
  • 2
  • Can you post an error message that you get? – Sebastian Piskorski Apr 04 '14 at 19:48
  • There is no error. Yep, I can not get the data stored in session. – light Apr 08 '14 at 14:07
  • I can hardly understand the first sentence from your question. Can you write something more? Where is the comma? How do you track the request? Do you make `var_dump` on `$_SERVER` variable? How do you try to pass information by session. – Sebastian Piskorski Apr 08 '14 at 14:21
  • There is the comma: `[HTTP_COOKIE] => , FRONTEND=vkq1nq69lhequ5v1v7kor2sj71` – ek9 Apr 11 '14 at 12:46
  • See http://stackoverflow.com/questions/22245852/codeigniter-session-failing-only-in-china as user is having similar problems there. No solution yet though. – ek9 Apr 11 '14 at 12:47
  • This seems to be a browser problem. Could you resolve this by using ltrim()? `$_SERVER['HTTP_COOKIE'] = ltrim($_SERVER['HTTP_COOKIE'], ',');` I'm assuming there is a reason you're relying on HTTP_COOKIE versus $_COOKIE? – Devon Bessemer Apr 17 '14 at 20:20
  • 2
    Could you print_r($_COOKIE) please? – verheesj Apr 21 '14 at 15:26
  • This seems like an Apache (or whatever web server you have) issue, because multiple Cookie request headers shouldn't be accepted. – Ja͢ck Apr 28 '14 at 07:30

1 Answers1

0

To me the application sets multiple cookies with the same name, one of it with an empty key and an empty value.

The browser receive the empty cookie and send it back the next request, thus having ", ..." instead of "key=value, ...".

I'd suggest you to inspect your application for wrong setcookie() and header('Cookie:') functions.

MarcoP
  • 190
  • 1
  • 6
  • If both key and value were empty, wouldn't you see "=, foo=bar"? – Ja͢ck Apr 28 '14 at 06:58
  • Should but not in this and other cases where it returns NULL or an empty string, also read https://bugs.php.net/bug.php?id=63835 – MarcoP Apr 28 '14 at 07:04
  • In this case the application sets two cookie pairs (one of which is empty) on the same cookie, the browser will send "one" request for that cookie adding all pairs previously set. – MarcoP Apr 28 '14 at 07:33
  • Are you saying that the server sent two `Set-Cookie:` headers for the same cookie name? – Ja͢ck Apr 28 '14 at 07:37