php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27451 Losing Session vars for unknown reason
Submitted: 2004-03-01 17:00 UTC Modified: 2004-03-11 09:54 UTC
Votes:11
Avg. Score:3.0 ± 1.0
Reproduced:2 of 4 (50.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: hamid at wannameet dot nl Assigned:
Status: No Feedback Package: Session related
PHP Version: 4.3.4 OS: FreeBSD
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: hamid at wannameet dot nl
New email:
PHP Version: OS:

 

 [2004-03-01 17:00 UTC] hamid at wannameet dot nl
Description:
------------
I am using sessions in a project of mine running on a virtual host, but i am losing vars from my session occassionaly. So not always and not in specific files.
The session itself is not lost and after reloading the session vars reappear.Unfortunately i cann't reproduce the error, but i have noticed the errors in my log file.
I also tried it with a custom session handler but the problem still exists.
And i do not get an error related to the session itself, therefor i suspect that it is a bug.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-01 17:11 UTC] derick@php.net
We can't really do anything with this information, but I do know that with a security update in IE session problems occurred.

Please come with some information with which we can try to reproduce, also first try the latest snapshot (php4-stable).
 [2004-03-01 17:41 UTC] hamid at wannameet dot nl
Unfortunately i cannot reproduce the problem because it occurs random and without any logic.
Also am i not in the position to try the latest snaphost because my site runs on a virtual host.

What kind of information do you prefer, to try and reproduce the problem?
 [2004-03-01 17:53 UTC] hamid at wannameet dot nl
// file settings.php

<?php

ini_set('error_reporting',E_ALL ^ E_NOTICE);
ini_set('log_errors','1');

function error_found($type, $msg, $file, $line)
{

		$referer = $_SERVER['HTTP_REFERER']; 
		$uri = $_SERVER['REQUEST_URI']; 
		$ip = getenv("REMOTE_ADDR");
		$host = getenv("REMOTE_HOST");
		$user_agent = getenv("HTTP_USER_AGENT");
		$protocol = getenv("SERVER_PROTOCOL");
		
		// define the log file
		$errorLog = "";
		
		// construct the error string 
		$errorString = "Date: " . date("d-m-Y H:i:s", mktime()) . "\n";
		$errorString .= "Error type: $type\n";
		$errorString .= "Error message: $msg\n";
		$errorString .= "Script: $file($line)\n";
		$errorString .= "Referer: $referer\n";
		$errorString .= "Request URI: $uri\n";
		$errorString .= "Protocol: $protocol\n";
		$errorString .= "Client: $user_agent\n";
		$errorString .= "Client IP: $ip\n\n";

		// write the error string to the specified log file
		if ($type!=8) { 
			$fp = fopen($errorLog, "a+");
			fwrite($fp, $errorString);
			fclose($fp);
		}
}

ini_set('display_errors','1');
set_error_handler("error_found");

$dbhost = "";
$dbname = "";
$dbuser = "";
$dbpwd = "";

$db = mysql_connect("$dbhost", "$dbuser","$dbpwd");
mysql_select_db("$dbname",$db);

include(object.session.php'); 

?>

// file 2

<? php

include("settings.php");

$sess_lang = $_SESSION['lang'];

echo $sess_lang; // bug?!

?>
 [2004-03-01 18:03 UTC] derick@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 avoid embedding huge scripts into the report.


 [2004-03-01 18:48 UTC] hamid at wannameet dot nl
you can find an example in a frameset on
http://www.wannameet.nl/bug_php/index.inc
http://www.wannameet.nl/bug_php/output.inc

rename the files to .php
 [2004-03-01 18:52 UTC] hamid at wannameet dot nl
i'm sorry you can find the files in
http://www.wannameet.nl/bug_php/

is an open dir
 [2004-03-01 19:07 UTC] hamid at wannameet dot nl
i have also put the error_log of yesterday in the directory bug_php, for extra info
 [2004-03-02 03:05 UTC] derick@php.net
That error log only shows that some files can not be opened, and sessions work fine for almost anybody (we had no other bug reports like this), so can you show something that proves your point in the form of a log? 
 [2004-03-02 05:35 UTC] hamid at wannameet dot nl
the include files could not be opened because sess_lang was empty, but i changed my error reporting so that it will capture session_id en sess_lang. You will receive the new log file as soon as it has some entries.
 [2004-03-02 15:06 UTC] idong at gmx dot de
Seems to me that if it is a special problem of $_SESSION along with session var name 'lang'. Try this:

<?php
session_start();

echo '<br><br><b>lang test';
$_SESSION['lang'] = 'de';
echo '<br>1 - '.$_SESSION['lang'];
$lang = 'en';
echo '<br>2 - '.$_SESSION['lang'];

echo '<br><br><b>no_lang test';

$_SESSION['no_lang'] = 'de';
echo '<br>1 - '.$_SESSION['no_lang'];
$no_lang = 'en';
echo '<br>2 - '.$_SESSION['no_lang'];
?>


What I get is this:

  lang test
  1 - de
  2 - en

  no_lang test
  1 - de
  2 - de

Maybe there are some more variable names one shouldn't use with sessions?
 [2004-03-02 15:42 UTC] hamid at wannameet dot nl
hi idong,

i tried your example, but the result i am getting is
de
de

de
de

with register_globals Off and On
 [2004-03-02 16:35 UTC] idong at gmx dot de
Hello Hamid,

Really strange...
I tried this again, after reading your comment and now I get:

lang test
1 - de
2 - en

no_lang test
1 - de
2 - en

I swear that I just copied and pastet the results of the script - both with my first posting and now with this one.

I tried it with register_globals on and register_globals off. This is really getting strange since you get a completely different result from my example and me, I got a different result (than the first time) too.

Anyway, the result from my last test (see above) isn't the expected behaviour either or am I making a mistake?

Ok, lets resume the problem at this point of time:

1. With the same example I got two different results. I changed nothing in between, only some time went by.

2. Again, using my example, YOU got a completely different result - the result I would have also expected from my own tests.

3. looking at my latest results, I can say that my first analysis (bug occurs on use of "lang" as session var name) was wrong.

4. YOU have the problem, that you are "losing vars from my session occassionaly"

Any help from the PHP crew? 
Thanks a lot, idong
 [2004-03-02 16:36 UTC] hamid at wannameet dot nl
i have put my latest error_log in the directory php_bug
as you can see the session exists but sess_lang and sess_referer are empty.

// error function

session_start();
$sess_lang = $_SESSION['lang'];
$sess_referer = $_SESSION['referer'];
$session_id = session_id();

$errorString .= "Session_id: $session_id\n";
$errorString .= "Sess_lang: $sess_lang\n";
$errorString .= "Sess_referer: $sess_referer\n";

//

the format for the include files is:
include("content/$sess_lang/filename.inc");
 [2004-03-02 16:48 UTC] hamid at wannameet dot nl
hi idong,

yeh i find it really strange too. Also because i am not getting any errors concerning the session itself.
And other annoying thing is the randomness of this problem, because when i try to invoke the error it is not occuring.

So i am really lost :( ;)

Although i am starting to suspect my hostingcompany
 [2004-03-06 11:53 UTC] hamid at wannameet dot nl
Here is a screenshot of my sessions db-table to prove the point of losing session vars.

http://www.wannameet.nl/error/session_screen.gif
 [2004-03-11 09:54 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 01:01:30 2024 UTC