This topic is locked

Set session variable in JavaScript OnLoad event

12/3/2018 4:13:11 PM
PHPRunner General questions
A
asawyer13 authorDevClub member

How can I Set a session variable in JavaScript OnLoad event and also how do I read the value back?
I tried as a test.

$_SESSION["Value"] = "35";


I'm sure I'm just doing something simple incorrectly.
Thanks

Alan

admin 12/3/2018

Sessions work on the web server. To set a session variable you need to use on of server side events. Javascript OnLoad event works in the web browser, you cannot set a session variable there.

woodey2002 12/4/2018

Have a look here proxy, see how I create a session variable and then use the proxy method to be able to work with that variable in Javascript.
Hope this helps,

J

A
ayctech 12/6/2018

can you assign a value to the session variable from javascript?



Have a look here proxy, see how I create a session variable and then use the proxy method to be able to work with that variable in Javascript.
Hope this helps,

J