使用jquery保存会话变量不会';好像不行

使用jquery保存会话变量不会';好像不行,jquery,session,Jquery,Session,我在存储会话时遇到问题 我正在使用的代码: //save to session $.session("compareLeftContent","value"); alert($.session("compareLeftContent")); 玩 有什么想法吗?您正在使用session.js吗 您需要使用$设置会话。session.set: $.session.set("compareLeftContent", "value"); alert($.session.get("co

我在存储会话时遇到问题

我正在使用的代码:

//save to session
    $.session("compareLeftContent","value");
    alert($.session("compareLeftContent"));


有什么想法吗?

您正在使用session.js吗

您需要使用
$设置会话。session.set

$.session.set("compareLeftContent", "value");
alert($.session.get("compareLeftContent"));
要检索会话值,请使用
$.session.get

$.session.set("compareLeftContent", "value");
alert($.session.get("compareLeftContent"));

在您提供的JSFIDLE示例中,没有附加会话插件<代码>$。jQuery中不包括会话。您需要使用此插件来实现以下功能:

然后使用
$.session.set
$.session.get
方法存储和读取会话密钥

例如:

$.session.set("compareLeftContent","value");
alert($.session.get("compareLeftContent"));

另一个答案似乎更完整,带有下载页面的链接。我实际上认为会话是由jquery本机处理的。。。愚蠢的我,因为我在文档中找不到任何东西。。。不管怎么说,你的答案是正确的。如果我们必须用饼干来储存的话