views:

242

answers:

1

Hi, I have found a weird difference in cookie behavior in IE+Safari/Opera+Firefox while navigating with the 'back' button:

in IE and Safari the cookies set on a page get dropped (reverted) when returning to the previous page via the 'back' button, while in Opera and Firefox the new cookies persist.

The latter behavior is what I need, but how do I implement it for IE and Safari, if that is even possible?

The cookies are set by the server and read using JQuery cookie API ($.cookie)

Thanks.

A: 

I have run into the exact opposite problem, in FF and Chrome. The cookies revert back to the cookies when the page is loaded. If a use chooses an option that changes a cookie, goes to another page, then clicks back, that change is lost. But the same scripts works fine in IE and Safari for me.

EDIT: I have just corrected persistence problems I was having with FF/Chrome by adding these PHP lines to my page:

header("Cache-Control: no-store, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");

It looked as if the browsers had different default rules for caching and one would have to specify which to use. Also using a dummy onBeforeUnload function like this:

window.onbeforeunload = function () {
    // return 'warning';
}

helps prevent the page from being cached without giving the end user an alert dialog.

I don't know if it helps, but I thought I'd give my two cents.

marcus