FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » session question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: session question [message #177666 is a reply to message #177665] Thu, 12 April 2012 16:56 Go to previous messageGo to previous message
Scott Johnson is currently offline  Scott Johnson
Messages: 196
Registered: January 2012
Karma:
Senior Member
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.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Date/Time warning
Next Topic: How to create an instance from a class name
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Dec 12 20:42:41 GMT 2024

Total time taken to generate the page: 0.03832 seconds