开发者

Cookie write fails to work on hosted site

I have created a b开发者_运维技巧asic but extensive javascript-html page that depends on cookies to keep user information. It runs perfectly on my computer (MAC - Firefox) but when loaded into my hosted web site (the page is in my domain) the cookies are not being written when the page is opened.

I was hoping that by keeping all the programming in javascript I could get some basic interactivity. Is this assumption wrong? Must the cookies be written using PHP?

My cookie writes are very vanilla.

document.cookie = cookieArray[ja]+expires+"; path=/"; // writes cookie data into browser.

update

well cookies are now being written since I added "path=/; domain=.my.org". But now there is one other problem. It seems that safari and Firefox write the cookies in reverse order to each other. I create the cookies by altering an array then simply stepping thru the array to write the cookies. I was hoping that I could simply read the cookies one by one and keep the order. Ah well.


Did you added the ";" between cookieArray[ja] and expires?

document.cookie = 'cookie-name=cookie-value; expires=Thu, 01-Jan-70 00:00:01 GMT;';

Also the cookieArray[ja] have to contain the cookie-name.

Do you really need the path? This parameter is also optional.

Cookies are, by default, available to all other files in the same directory the cookie was created in.

http://www.comptechdoc.org/independent/web/cgi/javamanual/javacookie.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜