php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71502 session not saving correct values
Submitted: 2016-02-03 08:59 UTC Modified: 2016-02-04 10:56 UTC
From: birger at bredelund dot dk Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.6.17 OS: win7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: birger at bredelund dot dk
New email:
PHP Version: OS:

 

 [2016-02-03 08:59 UTC] birger at bredelund dot dk
Description:
------------
---
From manual page: http://www.php.net/book.session
---
I have a problem with a specific registration in session.
PHP is actual version 5.5.1 - supplied with Wampserver 2.5
No changes to ini, og anything else special.

I have ekstensive use og $_SESSION - and everything functions as it is supposed to. Has been up till now, anyway.

A function - GetKode() - returns an arbritary string, from a given set of characteres.
Used for captcha.
So...
Save the result in $_SESSION and in a hidden input in the form.
The script that recieves data from the form, then compares the two.
And the problem is, that the values are not identical.

Renaming the varibale (captcha -> capkode for instance) does not give the same value in input line and $_SESSION
Been all over my code - the $_SESSION variable name is not in use anywhere else, and the error occurs even before submitting the form.
Running my own server, so I can actually check the session-file for content - and it is not as it should be, it is not the same string as the one in the HTML-input..
And the real problem is, that it is only this one variable - no matter what I call it... Theres around a hundred values in the $_SESSION - and only this one behaves like this.

I have done the same thing on other sites, with no problems....
It actually could look like, whenever the value of $_SESSION variable is called, the GetKode() function is the one returning the value. Don't really see how this could happen, tho...

Get Kode, ia capable of returning a string of fixed length og of random length.
If I set the length, the wrong data-entry is of the same length. If I do not, lengths vary (as expeccted).



Test script:
---------------
$_SESSION['captcha'] = GetCode();
echo '<input type="hidden" id="captha" value="'.$_SESSION['captcha'].'">';

also tried like this:
$capt = ((string)GetCode()); // Trying to make sure, its not cause by a "recall" of the function, but actually a store string value.
$_SESSION['captcha'] = $capt;
echo '<input type="hidden" id="captha" value="'.$capt.'">';

Same result.

Also tried adding
echo $capt."\n".$_SESSION['capkode'];
Whitch intering enough prints equal (correct) values - but it is not the one that is actually stored in $_SESSION....

Expected result:
----------------
You would expect the session and the input line to hold identical values - they don't

Actual result:
--------------
At my wits end.
What is happening here, is simply not possible...

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-02-03 09:08 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-02-03 09:08 UTC] requinix@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

If the code changes then GetCode() must be getting called, right? Use debug_backtrace() or debug_print_backtrace() in that function to make sure that it is being called exactly when you think it is.
 [2016-02-03 11:59 UTC] birger at bredelund dot dk
backtrace and print backtrace, agrees that the Getkode() function is called only once, from the line where the value is stored in $_SESSION, and nowhere else.
 [2016-02-04 10:56 UTC] birger at bredelund dot dk
FYI - Problem solved

Firfox make double calls.
Somewhere was an img tag without a filename given, so FF repeats the call to load the site into an img-tag.
Not really logical, but that is what happens.
So the script runs twice - except that the second call is terminated, and the result not displayed.
So the only apparent effect, is the change of content i $_SESSION....

Sorry to have bothered you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 01:01:28 2024 UTC