Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #5495

Re: session question

From Scott Johnson <noonehome@chalupasworld.com>
Newsgroups comp.lang.php
Subject Re: session question
Date 2012-04-12 09:56 -0700
Organization A noiseless patient Spider
Message-ID <jm71fg$vo3$1@dont-email.me> (permalink)
References <jm70n9$r71$1@dont-email.me>

Show all headers | View raw


On 4/12/2012 9:43 AM, William Gill wrote:
> I have a site with an input form that recursively calls itself via
> action="<?php echo $_SERVER['PHP_SELF']; ?>", and a couple links with
> url encoded data that indicate simple selections w/o using a form. It
> uses different include('file'); statements based on the progress and/or
> choices previously made, and it works fine, but is a little complicated
> to track "state" when troubleshooting, updating, or changing.
>
> I am thinking of using a session approach which would be simpler to
> follow, but have never used sessions on a page that is recursively called.
>
> First since session_start() would be called every iteration, that will
> cause an error unless I encapsulate it in an if loop to see if the
> session already exists. Is this the preferred method?
>
> Second, when the user is finished and receives an acknowledgement I plan
> to call a session_unset() to clear things up so that if they want to do
> it again, they are beginning with a clean slate. Again, is this the
> preferred method?
>
>

You won't get an error for calling session_start on a page that calls 
itself 'unless' you have it being called multiple times such as in one 
of your include files.

Each call to that page whether it is from another page or itself is a 
separate new call to that page and the session_start does not carry over.

Do not use session_unset unless you are on an old PHP install (4) i 
think, in which case get it updated

use the unset() method.

But I would not use that solely.

I personally empty each $_SESSION variable
with $_SESSION = array();

I guess you could use session_destroy() but I have not used this and am 
not sure how it behaves.

Sure someone will have some more info on this.





Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

session question William Gill <noreply@domain.invalid> - 2012-04-12 12:43 -0400
  Re: session question Scott Johnson <noonehome@chalupasworld.com> - 2012-04-12 09:56 -0700
  Re: session question "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-12 19:43 +0200
  Re: session question "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-12 19:59 +0200
  Re: session question Captain Paralytic <paul_lautman@yahoo.com> - 2012-04-13 02:18 -0700
  Re: session question Denis McMahon <denismfmcmahon@gmail.com> - 2012-04-13 13:27 +0000
    Re: session question William Gill <noreply@domain.invalid> - 2012-04-13 13:51 -0400
      Re: session question Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-13 15:54 -0400
      Re: session question William Gill <nospam@domain.invalid> - 2012-04-20 02:40 -0400
        Re: session question "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-20 10:55 +0200
        Re: session question Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-04-20 11:25 +0200
        Re: session question Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-20 08:11 -0400
          Re: session question William Gill <noreply@domain.invalid> - 2012-04-20 10:59 -0400
            Re: session question William Gill <noreply@domain.invalid> - 2012-04-20 11:32 -0400
            Re: session question Michael Fesser <netizen@gmx.de> - 2012-04-20 17:50 +0200
              Re: session question William Gill <nospam@domain.invalid> - 2012-04-20 12:04 -0400
                Re: session question Tim Streater <timstreater@greenbee.net> - 2012-04-20 18:17 +0100
                Re: session question "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-04-20 20:08 +0200
                Re: session question Tim Streater <timstreater@greenbee.net> - 2012-04-20 20:36 +0100
                Re: session question William Gill <nospam@domain.invalid> - 2012-04-21 18:13 -0400
                Re: session question Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-20 14:22 -0400
                Re: session question William Gill <nospam@domain.invalid> - 2012-04-20 15:04 -0400
                Re: session question The Natural Philosopher <tnp@invalid.invalid> - 2012-04-20 22:09 +0100
                Re: session question Michael Fesser <netizen@gmx.de> - 2012-04-20 21:13 +0200
                Re: session question Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-20 15:45 -0400
                Re: session question Tim Streater <timstreater@greenbee.net> - 2012-04-20 23:11 +0100
                Re: session question The Natural Philosopher <tnp@invalid.invalid> - 2012-04-20 23:23 +0100
                Re: session question Tim Streater <timstreater@greenbee.net> - 2012-04-21 13:14 +0100
                Re: session question Jerry Stuckle <jstucklex@attglobal.net> - 2012-04-20 18:45 -0400
                Re: session question Michael Fesser <netizen@gmx.de> - 2012-04-21 01:24 +0200
                Re: session question The Natural Philosopher <tnp@invalid.invalid> - 2012-04-21 01:28 +0100

csiph-web