3

I used the code provided by SpYk3HH on the page: "$.cookie is not a function" to set cookies for storing background images.

But the cookie i set is being set separately for home page from other pages specifically because of difference in path of cookies.

The paths being set are : path=/webapp/wcs/stores/servlet/en for home page and "path=/webapp/wcs/stores/servlet/" for all other pages. I am unable to set the path to path=/ using the js provided by SpYk3HH. It seems it does not have provision for setting path. see code for setting cookie: $.setCookie("backgroundImage", imageFile,); Please help or suggest a work around.

Also, when I try to use jquery.cookie.js instead of the js provide by SpYk3HH, i get an error $.cookie is not a function. I already tried changing the file name to jquery_cookie.js and also made sure that jquery is not being loaded more than once. Other option is to enable Mod_sec but I don't know how to do it.

Community
  • 1
  • 1

2 Answers2

2

Try this cookie plugin: https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js

Then just set your cookie like this: $.cookie(cookieName,cookieValue,{expires: 7, path: '/'});

Joche
  • 346
  • 7
  • 17
2

Are you sure jquery.cookie.js is being loaded after jQuery? And that your script for $.cookie [...] is being executed after the plugin is loaded?

Looks like a script positioning problem!

caulitomaz
  • 2,141
  • 14
  • 20