For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > March 2007 > newbie needs help with sessions....









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author newbie needs help with sessions....
angelduran2004@hotmail.com

2007-03-29, 7:00 pm

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.

Floortje

2007-03-29, 7:00 pm

angelduran2004@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['R
EQUEST_URI'];

foreach ($_SESSION['pages_visited'] as $page)
{
echo 'history: <a href = "'.$page.'">'.$page.'</a><br>';
}
--
Arjen
http://www.hondenpage.com
shimmyshack

2007-03-29, 7:00 pm

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.
>
> session_start();
> $_SESSION['pages_visited'][]=$_SERVER['R
EQUEST_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['R
EQUEST_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>

angelduran2004@hotmail.com

2007-03-30, 3:59 am

On Mar 29, 10:22 am, "shimmyshack" <matt.fa...@gmail.com> wrote:
> On 29 Mar, 16:04, Floortje <l...@zingmaarmetmijmee.enel> wrote:
>
>
>
>
>
>
>
>
>
> 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['R
EQUEST_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>- Hide quoted text -
>
> - Show quoted text -


yup. thank you. it works great. thank you so much.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com