简体   繁体   English

jQuery无法使用jquery.cookie插件读取cookie

[英]jQuery can't read cookie using jquery.cookie plugin

Hy, HY,

I'm developing a website in ASP.NET MVC 5 on my local machine. 我正在本地计算机上使用ASP.NET MVC 5开发网站。 I'm trying to read a cookie, which I've set by the backend. 我正在尝试读取由后端设置的cookie。 jQuery and the cookie plugin is included in my code. jQuery和cookie插件包含在我的代码中。 My code: 我的代码:

var test = $.cookie['test'];

The cookie "test" exist with following properties: cookie“ test”具有以下属性:

  • Name: test 名称:测试
  • Value: test 值:测试
  • Domain: localhost 域:本地主机
  • Path: / 路径:/
  • Expires: Session 过期:会话

I've read many posts about issues with cookies, but nothing worked for me. 我已经阅读了许多有关Cookie问题的帖子,但对我没有任何帮助。

$.cookie是一个函数,因此您需要调用它(最后使用()),您正在尝试读取一个称为test的属性。

var test = $.cookie('test');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM