Is it possible to a create session variable in JavaScript?

后端 未结 5 1486
情歌与酒
情歌与酒 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:19

    There are a number of ways of recording state in Javascript - none of which are particularly great / cross-browser, but there you go.

    You can set and get cookies - http://www.quirksmode.org/js/cookies.html

    Window.name storage (sessionvars) - http://www.thomasfrank.se/sessionvars.html - this is a very cool hack, but probably not a great idea to use for anything important

    HTML5 local storage - http://diveintohtml5.ep.io/storage.html

    Server-side is probably the way to go here, but client-side you have a few options.

提交回复
热议问题