是否可以在JavaScript中创建会话变量? [英] Is it possible to a create session variable in JavaScript?

查看:51
本文介绍了是否可以在JavaScript中创建会话变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在JavaScript中创建和更新会话变量?就像在PHP中一样,我启动会话并初始化会话变量。

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

我正在使用PHP的一些JavaScript函数。

I'm using some JavaScript function with PHP.

我只是JavaScript的初学者,所以也请给我一些好书。

I'm just a beginner in JavaScript so please also refer me some good books.

推荐答案

通常的含义术语会话变量是:存储在服务器上的一些数据,通过令牌与用户的会话相关联。

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".

假设您在谈论客户端JavaScript ,然后简短的回答是不,因为它在错误的计算机上运行。

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

您可以使用JS向服务器发出HTTP请求,并具有服务器端程序将数据存储在会话变量中。

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

您还可以使用JS在cookie中存储数据(而不是设置到期时间,以便在浏览器会话结束时到期)

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)

这篇关于是否可以在JavaScript中创建会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆