简体   繁体   中英

javascript cookie, Ember

I want to put a user input into a cookie to save the value for later display. It seems I can write into the cookie, but not able to get the value back. 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". I don't see why I don't get my value out, seems like a simple thing. Any help is much appreciated.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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