|
Posted by shimmyshack on 03/29/07 16:22
On 29 Mar, 16:04, Floortje <l...@zingmaarmetmijmee.enel> wrote:
> angelduran2...@hotmail.com schreef:> hi. since i'm new to php i don't know how to store data in sessions.
> > for example, suppose the user clicked on a link (e.g. "link1"), now
> > the user clicks on another link (e.g. "link2"). Now, how do i store
> > the data ("link1" and "link2") of what the user has been clicking or
> > viewing as the user goes along my site? if you could post some
> > example code it would be great. thank you for your time.
>
> session_start();
> $_SESSION['pages_visited'][]=$_SERVER['REQUEST_URI'];
>
> foreach ($_SESSION['pages_visited'] as $page)
> {
> echo 'history: <a href = "'.$page.'">'.$page.'</a><br>';}
>
> --
> Arjenhttp://www.hondenpage.com
in other words make 5 pages identical in every way using the following
code, now load one up in the browser and start clicking
<?php
session_start();
?><html>
<head></head>
<body>
<?php
$_SESSION['pages_visited'][]=$_SERVER['REQUEST_URI'];
foreach ($_SESSION['pages_visited'] as $page)
{
echo 'history: <a href = "'.$page.'">'.$page.'</a><br>'."\n";
}
?>
<hr>
<br>
<br>
<a href="index1.htm">index1</a>
<a href="index2.htm">index2</a>
<a href="index3.htm">index3</a>
<a href="index4.htm">index4</a>
<a href="index5.htm">index5</a>
</body>
</html>
[Back to original message]
|