php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28647 session code does not show same behaviour
Submitted: 2004-06-06 01:15 UTC Modified: 2004-06-07 08:54 UTC
Votes:2
Avg. Score:2.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: bill dot stevens at hotmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.3.7 OS: WindowsXP/Debian
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: bill dot stevens at hotmail dot com
New email:
PHP Version: OS:

 

 [2004-06-06 01:15 UTC] bill dot stevens at hotmail dot com
Description:
------------
using sessions on windows xp/php 4.3.7 and register_globals off does work fine (code below).

same script on debian-woody/php 4.3.1 and register_globals off does not read the session data. only register_globals on solves this (same code).

session-related config on both machines is the same or changes had no effect.

any ideas on config/scripting/stuff welcome :)

Reproduce code:
---------------
if( $this->useSessions )
{
	session_start();

	//	check, whether register globals is enabled
	if( ini_get( "register_globals" ) )
	{
		session_register( $this->sessionVar );
		if( !isset( $GLOBALS[$this->sessionVar] ) )
			$GLOBALS[$this->sessionVar]		=	array();
		$this->sessionData		=	&$GLOBALS[$this->sessionVar];
	}
	//	register globals is off, session_register is useless :-(
	else
	{
		if( isset( $_SESSION ) )
		{
			if( !isset( $_SESSION[$this->sessionVar] ) )
				$_SESSION[$this->sessionVar]	=	array();
			$this->sessionData		=	&$_SESSION[$this->sessionVar];
		}
		else
		{
			if( !isset( $GLOBALS["HTTP_SESSION_VARS"][$this->sessionVar] ) )
				$GLOBALS["HTTP_SESSION_VARS"][$this->sessionVar]	=	array();
			$this->sessionData		=	&$GLOBALS["HTTP_SESSION_VARS"][$this->sessionVar];
		}
	}
}

Expected result:
----------------
register session vars. works on windows, does not on debian.

Actual result:
--------------
no session on debian.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-06 11:27 UTC] wm at tolkienforum dot de
greetings

this must be somehow script related.

following code works on both windows/debian:

datei1.php:
-----------
<?php
session_start();
$normal=1;
session_register("normal");
$_SESSION['normal'] = 10;
header('Location: datei2.php');
?>


datei2.php:
-----------
<?php
session_start();
session_register("normal");
echo "Normal:". $_SESSION["normal"] ."<br><br>\n";
// prints "Normal:10"
?>


a bit weird your script works on win and does not on debian. since all the superglobals where introduced the session-coding changed. the docs include a lot of information (a lot of notice and caution stuff :p)

good luck :)
 [2004-06-06 14:50 UTC] hellno at home dot org
from php-doc:
> --------
> Caution: 
> --------
> If you are using $_SESSION (or $HTTP_SESSION_VARS), 
> do not use session_register(), session_is_registered(),
> and session_unregister(). 

so your files become:
<?php
  session_start();
  $normal=12;
  $_SESSION['normal'] = $normal;
  header('Location: datei2.php');
?>

<?php
  session_start();
  echo "Normal:". $_SESSION["normal"] ."<br><br>\n";
?>
 [2004-06-07 08:54 UTC] derick@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. 

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 09:01:28 2024 UTC