View Single Post
  #1  
Old 08-22-2006, 12:59 PM
euhoria euhoria is offline
Junior Member
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
euhoria is on a distinguished road
Default session variable overwriting

Hi,

i want to store a value in session array everytime page is called.

I am doing it like

PHP Code:
session_start();
$name = $_GET['name'];
$_SESSION[] = $name;

I am assuming that everytime page is loaded it will store name value automatically to the next index of session array, for example


PHP Code:
$_SESSION[0] = ist load
$_SESSION[1] = 2nd load
$_SESSION[2] = 3rd load



but it is overwriting the value at index 0 on every call like this,

PHP Code:
$_SESSION[0] = ist load //output array

$_SESSION[0] = 2nd load //output array

$_SESSION[0] = 3rd load //output array


and output array contains only one index 0 with the new value.

how can i store new values to next index of session array on every page call? -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
  Webmaster Forums - View Single Post - session variable overwriting
View Single Post
  #1  
Old 08-22-2006, 12:59 PM
euhoria euhoria is offline
Junior Member
 
Join Date: Aug 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
euhoria is on a distinguished road
Default session variable overwriting

Hi,

i want to store a value in session array everytime page is called.

I am doing it like

PHP Code:
session_start();
$name = $_GET['name'];
$_SESSION[] = $name;

I am assuming that everytime page is loaded it will store name value automatically to the next index of session array, for example


PHP Code:
$_SESSION[0] = ist load
$_SESSION[1] = 2nd load
$_SESSION[2] = 3rd load



but it is overwriting the value at index 0 on every call like this,

PHP Code:
$_SESSION[0] = ist load //output array

$_SESSION[0] = 2nd load //output array

$_SESSION[0] = 3rd load //output array


and output array contains only one index 0 with the new value.

how can i store new values to next index of session array on every page call? -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote