0

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?

5
  • You're trying to access a cookie that can't be accessed by javascript Commented May 14, 2012 at 18:59
  • Actually, suddenly I was unsure, secure cookies are often used with HTTPS, I was thinking of HTTPonly cookies, but not sure how the $.cookie plugin does this, but I'm guessing it either has something to do with SSL or it can no longer be accessed from JS. Commented May 14, 2012 at 19:03
  • I have also tried the following jquery cookie plugin and it didnt seem to work either. code.google.com/p/cookies/wiki/Documentation#Get_a_cookie Commented May 14, 2012 at 19:06
  • Is your cookie present in alert(document.cookie) output? Commented May 14, 2012 at 19:12
  • I checked that on HTTP protocol created secure cookie is deleted immediately. Possibly something is wrong with your HTTPS. Commented May 14, 2012 at 19:16

1 Answer 1

4

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?

Sign up to request clarification or add additional context in comments.

3 Comments

You could try console.log(document.cookie); to see what's available in the browser. If it's there it is the cookie plugin that is not able to read it, if it's not there, your server is'nt sending it for some reason, probably because of some SSL problem.
Thanks, I think it may actually be an SSL issue. We have had a dew other intermittent SSL issues recently. +1
Hi Adeneo, I am setting the cookie in Vaadin framework and try to read it in Ext-JS but I am not able to read it even if the application running in https protocol. Cookie set in Vaadin with secure = true, httpOnly = true but I can see the cookie in developer console in the browser. Could you please give an idea to resolve this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.