PHP adds "532142118" to session variable

I've got a very strange problem with hopefully a very simple explanation, but after hours of debugging I can't figure out what's happening.

LAMP stack is used, php 5.4

Here is a simplified version of the system wich still reproduces some strange behavior.

In a simple, self made framework, I made a horizontal menu (tabs) wich 'remembers' what url was active when the page in that tab is used for searching etc. So if you come back later to that tab, you immediately can see the last search results, because of the get parameters.

So one 'tab' in the menu, activates on this url:

/customer/2/customer_email/

This variable is put into a session variable: $_SESSION['tab_menu']['customer_email'] = $_SERVER['REQUEST_URI'];

After a page refresh, or navigating to another tab, the url of the tab can be read out of the session. BUT for some reason, the stored url is changed to:

/customer/2/customer_email/532142118

If I put GET parameters behind the url, the same strange number is inserted by ... whatever process. So if I access the tab with this url:

/customer/2/customer_email/?foo=bar

The session array will look like this on the same page load:

$_SESSION['tab_menu']['customer_email'] = /customer/2/customer_email/?foo=bar

But after I navigate to another page, the session data will read:

$_SESSION['tab_menu']['customer_email'] = /customer/2/customer_email/532142118

I verified that the $_SESSION array looks okay by var_dump($_SESSION) at the last point in the code. I verified that the $_SESSION data the next refresh is changed by dumping it's data right after session_start() in the beginning of the code.

If I do this, for testing, the strange number is not added in the session data:

$_SERVER['REQUEST_URI'] = '/customer/2/customer_email/';

If I navigate to another another url, the same problem will not occur:

/customer/3/customer_email/

More things I tried: C

  • Canged the keys used in the session array, but that didn't matter.
  • Tested on another server, with same setup, where this also doesn't occure.
  • Tried writing the session data right after I put the url in the session array, but that also won't solve anything.
  • Compared the variable $_SERVER['REQUEST_URI'] with the string '/customer/2/customer_email/' using strcmp(), strcasecmp(), viewing as HEX chars in Notepad++, using displaying as HEX in PHP itself using a found function on stackoverflow or php.net
  • Tried serializing the url before putting it into $_SESSION['tab_menu']['customer_email'], but then the number 532142118 is just added magically into the serialized data.
  • Tried decoding the number 532142118 but can't relate it to anything. It didn't change for two weeks.
  • Restarted the server
  • Almost completely rewrote logica that controls the 'tabs', system still hangs on that server variable.
  • Questions:

  • What is changing the session data? How can I debug this further?
  • Why is it not happening on all urls? I use this system for several tabs for a few years, and this is the first time this strange behavior is occuring.
  • Why does it occur when using the $_SERVER variable and not when adding it as self typed string?
  • What does this number mean? 532142118
  • Hoping on some reactions / input!

    Edit: added point 7 & 8 to "things I tried"


    FINALLY an answer !

    And thanks to this answer that pointed me in the right direction:
    PHP session variable changes between pages

    The pages I made, and that had problems with the session, are showing imported emails. Some emails are loading not existing images, with a html source of:

    <img border="0" width="110" height="114" id="_x0000_i1025" src="532142118" />
    

    So on the background, this would load the url appended with "532142118", completely integrated in network statistics and that would not show any visible var_dumps on the screen.
    I fell back to email myself function traces at the point where the session variable was set, to conclude the page was requested multiple times. The extra requested page, due to the image source, would malform the session and requested url.
    Now I exclude specific url requests to not put the url in the session variable, so wrong img sources will not affect the system :)

    Thank you all for the input !

    链接地址: http://www.djcxy.com/p/59728.html

    上一篇: php ajax控制会话变量消失

    下一篇: PHP向会话变量添加“532142118”