php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33142 Session info not getting saved correctly
Submitted: 2005-05-25 18:57 UTC Modified: 2005-06-12 14:34 UTC
From: jkump at everestgt dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 5.0.4 OS: Solaris 9
Private report: No CVE-ID: None
 [2005-05-25 18:57 UTC] jkump at everestgt dot com
Description:
------------
When using session_start() and coming into the page a second time.  The $_SESSION[] information is not getting saved correctly.  When returing to the page in an appropriate amount of time the session_start functions says the node no lionger exists.  Works correctly in php 4.3.11 but not in 5.0.4

Reproduce code:
---------------
<?php

session_start();
if (!$_SESSION["foo"]) {
  $_SESSION["foo"] = 45;
} else {
  print "found\n";
}
?>

Expected result:
----------------
secnd time called should say 

found.

Actual result:
--------------
Get warning messages about node no longer valid.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-26 00:37 UTC] sniper@php.net
Use 'isset($_SESSION['foo'])' and it will work just fine.
(you're setting it to non-false value..)

 [2005-05-26 02:35 UTC] jkump at everestgt dot com
That is fine.  I will try that but, this is the error that I am getting when I come back in and nothing is available in the $_SESSION superglobal.

[24-May-2005 16:06:22] PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Node no longer exists in /export/home/httpd/corp/my_everestkc_net/modules/BillOnline/session.class.php on line 64
[24-May-2005 16:06:22] PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent by (output started at /export/home/httpd/corp/my_everestkc_net/modules/BillOnline/session.class.php:64) in /export/home/httpd/corp/my_everestkc_net/modules/BillOnline/session.class.php on line 64
[24-May-2005 16:06:22] PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /export/home/httpd/corp/my_everestkc_net/modules/BillOnline/session.class.php:64) in /export/home/httpd/corp/my_everestkc_net/modules/BillOnline/session.class.php on line 64

These show up on the second trip into the code.  I cant initialize the session again.

When I assign stuff to $_SESSION['foo'] and then exit the script.  come back into the script via a link on the page.  The session is no longer valid and the $_SESSION info is gone.  The code works correctly in php 4.3.11.  and it fails on 5.0.4.  

I can try and setup an external area so you can see what is happening.

THanks
 [2005-05-26 19:40 UTC] sniper@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.

This is not a support forum where you ask how to use PHP..
(Thre is no bug here, sessions work just fine)

 [2005-06-02 23:01 UTC] jkump at everestgt dot com
This problem occurs when simplexml_load_string is used within the session.
 [2005-06-07 06:34 UTC] jkump at everestgt dot com
Please check this bug report with regard to sessions and simplexml_load_string()

Thanks
 [2005-06-08 02:40 UTC] sniper@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try to avoid embedding huge scripts into the report.


 [2005-06-08 20:38 UTC] jkump at everestgt dot com
It seems as though the simplexml_load_string object is clobbering the Session object.

http://www.fastcarrot.net/index.php
 [2005-06-11 19:50 UTC] sniper@php.net
Impossible to test without a script -> bogus.
(can not reproduce)

 [2005-06-11 23:34 UTC] jkump at everestgt dot com
Here is the flaming script.


<?php
ini_set(display_errors, on);
session_start();

$XML='<?xml version="1.0" encoding="UTF-8"?>
      <book type="paperback">
	      <title>Red Nails</title>
	      <price>$12.99</price>
	      <author>
		      <name> 
		        <first>Robert</first>
		        <middle>E</middle>
		        <last>Howard</last>
		      </name>
		      <birthdate>9/21/1977</birthdate>
	      </author>
       </book>
    ';

$HTML_XML='&lt;?xml version="1.0"?&gt;

&lt;book type="paperback"&gt;
	&lt;title&gt;Red Nails&lt;/title&gt;

	&lt;price&gt;$12.99&lt;/price&gt;
	&lt;author&gt;
		&lt;name&gt; 
		  &lt;first&gt;Robert&lt;/first&gt; 
		  &lt;middle&gt;E&lt;/middle&gt;
		  &lt;last&gt;Howard&lt;/last&gt;
		&lt;/name&gt;
		&lt;birthdate&gt;9/21/1977&lt;/birthdate&gt;
	&lt;/author&gt;

&lt;/book&gt;
';
$InXML = simplexml_load_string($XML);

if (!isset($_REQUEST["SUBMIT"])) {
  $_SESSION["PRICE"] = $InXML->price;
}

echo "<html>\n";
echo "<head><title>Test PHP BUG 33142</title></head>\n";
echo "<body>\n";
echo "<P>XML we are using: <pre>".$HTML_XML."</pre></P>\n";
echo "<BR><BR>\n";
if (isset($_SESSION["PRICE"])) {
  echo "<P>PRICE before submit: ".$_SESSION["PRICE"]."</p>\n";
}
if (isset($_SESSION["PRICE"]) && isset($_REQUEST["SUBMIT"])) {
  echo "<P>PRICE after submit: ".$_SESSION["PRICE"]."</p>\n";
}
echo "<form action=\"".$_REQUEST["PHP_SELF"]."\" method=\"POST\">\n";
echo "<input type=\"SUBMIT\" name=\"SUBMIT\" value=\"Get Price\">\n";
echo "</form>\n";

echo "</body>\n";
echo "</html>\n";
?>
 [2005-06-12 14:34 UTC] sniper@php.net
You need to cast the stuff for it to become a string.

$_SESSION["PRICE"] = (string) $InXML->price;


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 10:01:31 2024 UTC