I am trying to set session value in javascript :
//session value 5400
//remainingSeconds value 5399
@Session["remain-seconds"] = remainingSeconds;
But i am getting the following error:
invalid left-hand side in assignment
Is it possible to set session variable inside javascript?
I am trying to set session value in javascript :
//session value 5400
//remainingSeconds value 5399
@Session["remain-seconds"] = remainingSeconds;
But i am getting the following error:
invalid left-hand side in assignment
Is it possible to set session variable inside javascript?
Share Improve this question edited Feb 1, 2016 at 20:32 inverted_index 2,4371 gold badge23 silver badges46 bronze badges asked Feb 1, 2016 at 20:22 ucnobi ucnobiucnobi ucnobi 2551 gold badge6 silver badges16 bronze badges 2- 2 Sessions cannot be accessed by JavaScript – jasonwarford Commented Feb 1, 2016 at 20:25
- @jasonwarford Are you sure ? – ucnobi ucnobi Commented Feb 1, 2016 at 20:26
1 Answer
Reset to default 2No, session variables are server side. You'd have to have a little ajax call to talk to the server to set it. There are plenty of examples of this via google searches. You can see one example here.
For a one-time evaluation (on the server, before it hits the client), you can set it (sort of) in the code section of your script, but I think that's different from what you're asking to do. See this thread.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744909654a4600469.html
评论列表(0条)