Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I read cookies on client side ? #32

Closed
pmalek opened this issue Feb 1, 2014 · 1 comment
Closed

How can I read cookies on client side ? #32

pmalek opened this issue Feb 1, 2014 · 1 comment

Comments

@pmalek
Copy link

pmalek commented Feb 1, 2014

I have just tested this plugin and I have successfully set a cookie in my sails.js application with following code:

    Cookies = require("cookies"),
    Keygrip = require("keygrip"),
    keys = Keygrip(["SEKRIT2", "SEKRIT1"], 'sha256'),

...

    var cookies = new Cookies( req, res, keys );
    cookies.set("username", username, {signed: true});

and I can see this cookie using "Edit this cookie" chrome dev plugin but I cannot read it using jquery

console.log( JSON.stringify($.cookie()) );
var username = $.cookie("username"); 

$.cookie() is empty and $.cookie("username") is undefined.

@pmalek
Copy link
Author

pmalek commented Feb 1, 2014

Ok, I didn't read the documentation. I had to set httpOnly to false

 cookies.set("username", user.username, {signed: true, httpOnly: false});

@pmalek pmalek closed this as completed Feb 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant