Josh Mein
Josh Mein

Reputation: 28635

How can I get the value of a secure cookie with jQuery?

I am currently using jquery.cookie to get/create cookies on a website; however, I am having trouble getting the value of a secure cookie.

The plugin creates the secure cookie just fine using the following code:

$.cookie('myCookie', 'myValue', { expires: 365, secure: true });

I am then using the following code to retrieve the value:

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

Unfortunately this does not work and the value null is always returned. Can anyone see what I may be doing wrong?

Upvotes: 0

Views: 10830

Answers (1)

adeneo
adeneo

Reputation: 318182

The documentation says:

The secure attribute of the cookie will be set and the cookie transmission will require a secure protocol (like HTTPS).

Are you using HTTPS with a valid SSL certificate, or something similar, if not it will probably not work?

Upvotes: 4

Related Questions