user1810414
user1810414

Reputation: 113

jQuery cookie behaves differently on local machine vs production server

I'm setting a jQuery cookie for some site javascript effects. I'm setting expiration date to 30 days.

On local development machine cookie expiration is set properly, whereas on production expiration is being set to end of session. After inspecting the created cookies with web develoer tools, everything is identical except production machine cookie is marked as "session cookie" and setting expiration is disallowed, while cookie created on local development machine is not set to "session" and expiration date is editable.

Is there a way to make production machine cookie accept the expiration date?

This is how I set the cookie:

$.cookie('skip_animation','skip', 2592000);

Using jQuery 1.6.4 (legacy site)

All browsers behave the same way

Upvotes: 1

Views: 490

Answers (2)

Tina
Tina

Reputation: 11

What syntax is this? According to https://github.com/carhartl/jquery-cookie/blob/master/README.md, the third argument should be an object. Give it an 'expires' attribute in days to give the cookie some lifetime.

Upvotes: 1

Gogowitsch
Gogowitsch

Reputation: 1222

The reason is very likely not related to jQuery or its cookie plugin.

Do search for differences in relevant browser settings, protocol (http vs. https) and URL.

EDIT: Is the time on the production server set correctly? Is the session cookie transmitted to the server (the browser doesn't know that it's JS-only)? Maybe the cookie is actively reset by some component?

Upvotes: 0

Related Questions