I am working on an exercise in javascript where you have can choose between four different css-files. So far so good.
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.
Bookmarks