Is it possible to a create session variable in JavaScript?

后端 未结 5 1532
情歌与酒
情歌与酒 2021-01-05 09:50

Is it possible to create and update a session variable in JavaScript? Just like in PHP as I start sessions and initialize session variable.

I\'m using some JavaScrip

5条回答
  •  孤独总比滥情好
    2021-01-05 10:13

    The usual meaning of the term "Session variable" is: "Some data stored on the server, which is associated with a user's session via a token".

    Assuming you are talking about client side JavaScript, then the short answer is "no" as it runs on the wrong computer.

    You could use JS to make an HTTP request to the server, and have a server side programme store data in a session variable.

    You could also use JS to store data in a cookie (and not set an expiry time so it expires at the end of the browser session)

提交回复
热议问题