Page 1 of 1

Session Management

Posted: Wed Jul 24, 2013 3:51 am
by MrWizard.
Does anyone have a working examples of session management ?

I have attempted to use the 'start session' and $_SESSION as referenced in the documentation have encountered issues and the documentation seems week.

Questions;
- How do you test if a session is already active?
- In a given dynamic html page, do you need to open with 'start session' and close the page with a 'stop session' ?
- How do you set developer defined key/value pairs?
- Is there a list of $_SESSION keys exposed to the developer?
- Are any other $_ arrays exposed like; $_ENV or $_COOKIE

Thanks,
E

Re: Session Management

Posted: Wed Oct 09, 2013 4:34 am
by icouto
I have just started playing with sessions myself. I'll try to answer some of your questions, but others more knowledgeable than me might have better answers...:
MrWizard. wrote:- How do you test if a session is already active?
Unless you have explicitly started a session (with "start session"), then there is no active session.
- In a given dynamic html page, do you need to open with 'start session' and close the page with a 'stop session' ?
The "stop session" command is used to save the session data to disk. You will usually call it after adding some data to the session array - not necessarily when the user is closing or leaving a page.
- How do you set developer defined key/value pairs?

Code: Select all

put "value" into $_SESSION["key"]
- Is there a list of $_SESSION keys exposed to the developer?
All the keys in $_SESSION.
- Are any other $_ arrays exposed like; $_ENV or $_COOKIE
Yes, there are several - like $_COOKIE, $_POST, $GET, $_SERVER and more. Go to the API page, and do a search for "$_":
http://livecode.com/developers/api/6.0.2/

I hope this helps!

I have some session questions of my own, which I have not been able to find answers for anywhere in the documentation, such as: is there any XSS protection built-in? - i.e., is the session owner's authenticity verified solely by a cookie id, or does the session handler also check things like IP address and browser agent?

Re: Session Management

Posted: Fri Oct 10, 2014 1:28 am
by sturgis
You can find a very simple session example here: http://forums.livecode.com/viewtopic.ph ... ion#p50034