My problem is that I need to create a cookie that remember which css-file you choose if you have been at this site before. I have tried to solve this with document.cookie = "filename.css". This works perfect at my computer, if I put it out to my server it doesn't work at all. Could someone please help me?
First of all, cookies work with NVP (Name Value Pair); all you are providing is the V, without the N. ("filename.css"). You need to do document.cookie = "thisFile = filename.css;";
Secondly, without an expire date the cookie is not planted on the user's hard drive; it's a session cookie that disappears as soon as you close the browser.
Thanks for your fast reply and help!
could something like this work?
document.cookie = '"thisFile = filename.css;"; expires=Thu, 4 Aug 2011 20:47:11 UTC; path=/'
Originally Posted by sunny_days
You don't put quotes around the variable name or value. Path is really unnecessary, except for real detailed stuff.
document.cookie = 'thisFile = filename.css; expires=Thu, 4 Aug 2011 20:47:11 UTC;'