Is it possible to a create session variable in JavaScript?

javascript

Solution

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)

Problem

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 JavaScript function with PHP. I'm just a beginner in JavaScript so please also refer me some good books.

Original source