php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21083 Table variable not correctly working as session cookie
Submitted: 2002-12-18 13:40 UTC Modified: 2002-12-22 00:57 UTC
From: eetimle at tpu dot fi Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.2.3 OS: Win98SE
Private report: No CVE-ID: None
 [2002-12-18 13:40 UTC] eetimle at tpu dot fi
First here's the whole script:

<?php

session_start();

if(!session_is_registered('ind'))
{
	$ind = 0;
	session_register('ind');
	$table[$ind] = 1;
	session_register("table");
}
else
{
	$ind = $_SESSION['ind'];


	//Lis?t??n alkio tauluun
	$table[$ind] = 1;
	session_register("table");
}

//increases the index
$ind++;

$_SESSION['ind'] = $ind;

$i= 0 ;

//prints all the data in $table
while ($i < $ind)
{
	print("$table[$i]<br>");
	$i++;
}

?>

I have tested this script both Linux(script works perfectly) and Win98SE(doesn't work). Both have Apache and PHP 4.2.3.

So I'm using session cookie $table where to store number 1 in each index. Index increases every time i press refresh. Script should print (after three refresh):
1
1
1
1

But with my Windows scripts prints (after three refresh):

Notice: Undefined offset: 0 in c:\www\sessio_taulu_testi.php on line 32


Notice: Undefined offset: 1 in c:\www\sessio_taulu_testi.php on line 32


Notice: Undefined offset: 2 in c:\www\sessio_taulu_testi.php on line 32

1


When entering the script for the first time scripts prints correctly:
1

I have deleted the session file after each time I've executed the script, so that shouldn't be the problem.


I would like to know what's the problem in here :)

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-18 14:29 UTC] eetimle at tpu dot fi
Here's the script that works both Linux&Win98SE

session_start();

if(!session_is_registered('ind'))
{
	$ind = 0;
	session_register('ind');

	session_register("table[$ind]");
	$_SESSION["table[$ind]"] = 1;
}
else
{
	$ind = $_SESSION['ind'];

	//Lis?t??n alkio tauluun
	session_register("table[$ind]");
	$_SESSION["table[$ind]"] = 1;
}

//increases the index
$ind++;

$_SESSION['ind'] = $ind;

$i= 0 ;

//prints all the data in $table
while ($i < $ind)
{
	print($_SESSION["table[$i]"] . "<br>");
	$i++;
}
 [2002-12-22 00:57 UTC] iliaa@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: Thu Aug 15 07:01:28 2024 UTC