Sessions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dan Walker

    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


  • Andy Hassall

    #2
    Re: Sessions

    On Sat, 8 Nov 2003 17:00:04 +0000 (UTC), "Dan Walker" <dan.j.walker@t alk21.com>
    wrote:
    [color=blue]
    >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.[/color]

    <?php session_start() ; ?>
    <pre>
    <?php
    if (isset($_SESSIO N['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)

    Comment

    • Dan Walker

      #3
      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:lk9qqv0cbf ek50snve9jn78vm qbgp90iip@4ax.c om...[color=blue]
      > On Sat, 8 Nov 2003 17:00:04 +0000 (UTC), "Dan Walker"[/color]
      <dan.j.walker@t alk21.com>[color=blue]
      > wrote:
      >[color=green]
      > >Please can someone provide a nice simple script to test if my php is[/color][/color]
      setup[color=blue][color=green]
      > >properly for sessions. Just a little 2 page thing to prove that it is me
      > >that is the problem would be excellent. Thanks.[/color]
      >
      > <?php session_start() ; ?>
      > <pre>
      > <?php
      > if (isset($_SESSIO N['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)[/color]


      Comment

      • Pedro Graca

        #4
        Re: Sessions

        Dan Walker wrote:[color=blue]
        > 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.[/color]

        I use this:

        <?php
        session_start() ;

        if (isset($_GET['reset'])) {
        unset($_SESSION['counter']);
        session_unset() ;
        session_destroy ();
        session_start() ;
        $_SESSION['counter'] = 0;
        }
        if (!isset($_SESSI ON['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

        Comment

        Working...