Sessions / server

Hi!

I’d like to connect to a server script (PHP) which stores a session. When using a browser technique like Flash, the session is kept alive. However, when Unity does a POST or GET call to the server the session is lost.

How can I keep the session alive - secure - and store stuff in the $_SESSION superglobal?

Thanks!!

You can pass data in WWWForms 3rd parameter, use them to send stuff you previously retrieved

Honestly I would store the stuff in a database, or in playerprefs.

The session thing might work, but it could end without warning, as opposed to a database, which would keep all your info.

What I like to do is to generate a captcha ( CAPTCHA - Wikipedia) that I can later on validate in a form.

For this I need to store the actual value of the captcha in a session, and compare values in a form post later on.

I need sessions to do this in a secure way.

How would I do that using your database approach?

You can store the Captcha value in the database, after generation.
You can load the Captcha image into your app using WWW.Texture.

What I would do as well would be to have a request key.

Stage 1:
Captcha Image Generated
Captcha Value Generated
Request Key Generated.

Stage 2:
Captcha Value and Request Key stored in Database.

Stage 3:
Captcha Image loaded into App through WWW Texture.
Request Key loaded into App using WWW Data.

Stage 4:
User Response to Captcha and Request Key sent using WWW Form.
PHP page receives the Response and Key from the Form, searches through the database for a match to the key, then compares the stored value with the Response value.

No sessions, very secure, includes Captcha/Image verification.