Page 1 of 1

Sessions question

Posted: Wed Oct 22, 2003 11:15 am
by jgoluch
Hi,

I'm trying to find a way to keep array contents static (i.e. retained) thru multiple page loads/refreshes. From what I can tell, sessions might be the way to go. The examples I've seen so far show sessions as a way to transfer array contents across different pages. My question: Can sessions be used to retain array contents (i.e. not have the array re-initialize) upon a single page reload/refresh ? Any examples of such...?

Thanks,

John

Posted: Wed Oct 22, 2003 11:56 am
by d3ad1ysp0rk

Code: Select all

<?PHP session_start();
$_SESSION['var'] = $pagevar; ?>
<html>
<body>
<?PHP echo "$pagevar"; ?>
</body>
</html>
not sure if you can use arrays in sessions, but if you can, it'd be like this:

Code: Select all

<?php
for(int i=0;i<num;i++)
{
$_SESSION['something[i]'] = $something[i];
}
?>
(num = number of things in the array)
that would save all the array variables to session variables