This is a discussion on Sessions within the PHP Language forums, part of the PHP Programming Forums category; Please can someone provide a nice simple script to test if my php is setup properly for sessions. Just a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Sat, 8 Nov 2003 17:00:04 +0000 (UTC), "Dan Walker" <dan.j.walker@talk21.com>
wrote: >Please can someone provide a nice simple script to test if my php is setup >properly for sessions. Just a little 2 page thing to prove that it is me >that is the problem would be excellent. Thanks. <?php session_start(); ?> <pre> <?php if (isset($_SESSION['test'])) echo "Previous session variable value: {$_SESSION['test']}\n"; $_SESSION['test'] = rand(1,100); echo "New session variable value: {$_SESSION['test']}\n"; ?> </pre> -- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) |
|
|||
|
That is excellent. This at least proves that it is me at fault.
Thank you so much. Dan "Andy Hassall" <andy@andyh.co.uk> wrote in message news:lk9qqv0cbfek50snve9jn78vmqbgp90iip@4ax.com... > On Sat, 8 Nov 2003 17:00:04 +0000 (UTC), "Dan Walker" <dan.j.walker@talk21.com> > wrote: > > >Please can someone provide a nice simple script to test if my php is setup > >properly for sessions. Just a little 2 page thing to prove that it is me > >that is the problem would be excellent. Thanks. > > <?php session_start(); ?> > <pre> > <?php > if (isset($_SESSION['test'])) > echo "Previous session variable value: {$_SESSION['test']}\n"; > > $_SESSION['test'] = rand(1,100); > echo "New session variable value: {$_SESSION['test']}\n"; > ?> > </pre> > > -- > Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) > Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) |
|
|||
|
Dan Walker wrote:
> Please can someone provide a nice simple script to test if my php is setup > properly for sessions. Just a little 2 page thing to prove that it is me > that is the problem would be excellent. Thanks. I use this: <?php session_start(); if (isset($_GET['reset'])) { unset($_SESSION['counter']); session_unset(); session_destroy(); session_start(); $_SESSION['counter'] = 0; } if (!isset($_SESSION['counter'])) { $_SESSION['counter'] = 0; } echo 'SID = ', session_id(), '<br/>counter: ', $_SESSION['counter'], '<br/>'; echo '<a href="', $_SERVER['PHP_SELF'], '">add one</a> -- <a ', 'href="', $_SERVER['PHP_SELF'], '?reset">reset</a>'; ++$_SESSION['counter']; ?> But I don't know why session_id doesn't change at every reset :o -- ..sig |