Sessions

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-08-2003
Dan Walker
 
Posts: n/a
Default Sessions

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.

Dan


Reply With Quote
  #2 (permalink)  
Old 11-08-2003
Andy Hassall
 
Posts: n/a
Default Re: Sessions

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)
Reply With Quote
  #3 (permalink)  
Old 11-08-2003
Dan Walker
 
Posts: n/a
Default Re: Sessions

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)



Reply With Quote
  #4 (permalink)  
Old 11-08-2003
Pedro Graca
 
Posts: n/a
Default Re: Sessions

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0