Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix the case when the cookie string started with "; " #117

Closed
wants to merge 1 commit into from

2 participants

@jerryluk

We have seen sometimes IE 7 returns a cookie string starting with "; ", since the first cookie value in this case would be null, using $.cookie() to get other cookie values will always return null.

@carhartl
Owner

Probably the same as #88.

@carhartl
Owner

Should be combined or be fixed anyway with #104.

@carhartl carhartl referenced this pull request
Closed

Cookie Not working in IE9 #119

@carhartl carhartl closed this pull request from a commit
@carhartl Fixing IE issue, where cookie values were not read correctly because
of duplicate occurrences of "; ", fixes #88, fixes #117.
fd254dd
@carhartl carhartl closed this in fd254dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 9, 2012
  1. @jerryluk

    Fixed the case where the cookie string returned from browser are star…

    jerryluk authored
    …ted with '; firstkey=value...'
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  jquery.cookie.js
View
2  jquery.cookie.js
@@ -47,7 +47,7 @@
// read
var decode = config.raw ? raw : decoded;
- var cookies = document.cookie.split('; ');
+ var cookies = document.cookie.replace(/^;\s*/, '').split('; ');
for (var i = 0, parts; (parts = cookies[i] && cookies[i].split('=')); i++) {
if (decode(parts.shift()) === key) {
var cookie = decode(parts.join('='));
Something went wrong with that request. Please try again.