简体   繁体   English

javascript cookie,Ember

[英]javascript cookie, Ember

I want to put a user input into a cookie to save the value for later display. 我想将用户输入内容放入Cookie中,以保存该值以供以后显示。 It seems I can write into the cookie, but not able to get the value back. 看来我可以写入Cookie,但无法取回值。 I have this simple test set up: 我有一个简单的测试设置:

            var test = "TEST"; 
            document.cookie = "usr=TEST;";
            $.cookie("usr", test); 
            Ember.$.cookie('usr', test); 
            console.log("COOKIE", $.cookie("usr"), Ember.$.cookie('usr'), "cookie.length=", document.cookie.length);

Which results to the output "COOKIE undefined undefined cookie.length=0". 结果是输出“ COOKIE undefined undefined cookie.length = 0”。 I don't see why I don't get my value out, seems like a simple thing. 我不明白为什么我没有发挥自己的价值,这看起来很简单。 Any help is much appreciated. 任何帮助深表感谢。

我发现了问题-需要从本地主机运行项目以进行测试。

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

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