Forum Moderators: coopster
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?
$tmpvars = $_SESSION['myvars'];
$tmpvars[] = "next one, please";
....
$_SESSION['myvars']= $tmpvars
.. or if you can handle the array myvars directly. Not tested, just to give you an idea.