Forum Moderators: open

Message Too Old, No Replies

Getting session-variables to PHP from JavaScript

         

kjelle392

9:58 am on Nov 29, 2009 (gmt 0)

10+ Year Member



Hello friends!

I'm just beginning with JavaScript (and Ajax).

My loginscript now works with Ajax - that is; the script is sending a request to the servers PHP script to check username and password, but I wonder what that script should return - and how to use that response.

Either XML or pure text: The response is now "false" if the user couldn't log in for some reason, and the users ID and real name if the login went well...

But then the problem: if login IS ok - so that the users ID and real name is returned from the serverscript - I would like to store those variables in a session variable ($_SESSION in PHP). How do I get those variables back to the client script from JavaScript?

Hope someone understand the problem.

Best regard

Kjell Inge Sandvik
Norway

whoisgregg

8:17 pm on Dec 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The server's PHP script should set the session values. Only the session ID is stored in the cookie, not the values themselves. So Javascript doesn't set/get session values directly at all.