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

cookies[i].split is not a function #4

Open
DesMas opened this issue Apr 3, 2013 · 4 comments
Open

cookies[i].split is not a function #4

DesMas opened this issue Apr 3, 2013 · 4 comments
Assignees

Comments

@DesMas
Copy link

DesMas commented Apr 3, 2013

Hi

After adding the script to my project i have the following error visible in the firebug console:
TypeError: cookies[i].split is not a function

thrown by "var kv = cookies[i].split('=');" inside "_initCache: function()"

Situation as is: there are no cookies from that domain.
May it be that there is an error handling missing, if cookies is not filled correctly?

@AlexChittock
Copy link
Owner

I think that sounds like the likely cause, I'll investigate in a bit.

@ghost ghost assigned AlexChittock Apr 4, 2013
@pritesh-modi
Copy link

Hi Alex,
This issue is also arise for me.
If cookies are not set correctly, it shows error.

TypeError: cookies[i].split is not a function
var kv = cookies[i].split('=');

Please help to solve it.
Thanks

@yavir-me
Copy link

Hi, DesMas replace _initCache method with this:
_initCache: function () {
var cookies = document.cookie.split(';');
this._cookieCache = {};
for (var i in cookies) {
if (!isNaN(i)) {
var kv = cookies[i].split('=');
if ((new RegExp(this._generatePrefix() + '.+')).test(kv[0]) && kv[1]) {
this._cookieCache[kv[0].split(':', 3)[2]] = kv[1];
}
}
}
},

In jquery.session.js file.
Regards, Andrey4luck.

@yasrebi
Copy link

yasrebi commented Sep 23, 2021

thanks

Hi, DesMas replace _initCache method with this:
_initCache: function () {
var cookies = document.cookie.split(';');
this._cookieCache = {};
for (var i in cookies) {
if (!isNaN(i)) {
var kv = cookies[i].split('=');
if ((new RegExp(this._generatePrefix() + '.+')).test(kv[0]) && kv[1]) {
this._cookieCache[kv[0].split(':', 3)[2]] = kv[1];
}
}
}
},

In jquery.session.js file.
Regards, Andrey4luck.

its working for me 😀

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

5 participants