|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-01-31 04:50 UTC] nail at bowling dot nsk dot su
Following code the shows strange bag.
When function t() called as object method, variable 'time' is not kept in session.
Register_globals is On.
<?php
session_start();
class Test {
var $mT = array();
// this function does not deal with session
function t()
{
reset($GLOBALS);
while (list($k,$v)=each($GLOBALS))
$GLOB[$k]=$v;
$this->mT['TEST'] = $GLOB;
}
}
$test = new Test;
$test->t(); // comment this line and script will work right
?>
<pre>
<?php
print_r($_SESSION);
$_SESSION['time'] = time();
session_register('time');
echo "\n-------new _SESSION:-----------\n\n";
print_r($_SESSION); echo "\n";
?>
</pre>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 23:00:01 2025 UTC |
I mean value of $_SESSION['time'] lost at refresh. When I comment line $test->t() script works correctly: Array ( [time] => 1012549372 ) ------------------new _SESSION:-------------------------- Array ( [time] => 1012549373 ) When I remove comment the output is like this (don't forget begin new session): Array ( ) ------------------new _SESSION:-------------------------- Array ( [time] => 1012549537 )I have this bug on Windows 2000 PHP 4.2.1. $member = $auth->create_member_object($login, $password); $_SESSION["member"] = $member; $member->init(); ... $member->init() redirects the session to another page That page starts: <? require ("includes/common.php"); $member = $_SESSION["member"]; ... I have this bug regardless of the order of the following lines: require ("includes/common.php"); $member = $_SESSION["member"]; session_start() ... The output is: Notice: Undefined index: member in [file].php on line 4The problem still here. I wonder why you haven't fixed yet! 6 years passed!!!! The problem is next: I have 3 files: ------ session.php ---------- class Session { function Session() { session_start(); } function RegObject($object) { session_register('object_instance'); $_SESSION['object_instance'] = $objects; } function GetObject() { return $_SESSION['object_instance']; } } -------- addObject.php -------------- $session = new Session(); $obj = new ObjectClass(); $session->RegObject($obj); --------- getObject.php ------------- $session = new Session(); $obj = $session->GetObject(); print ">>>".$obj; // Here as output should be error that ObjectClass could not be converted to string, but only ">>>" printed The root of the problem seams in accessing $_SESSION.