Javascript 当我多次刷新页面时,Cookie将被销毁

Javascript 当我多次刷新页面时,Cookie将被销毁,javascript,php,jquery,cookies,Javascript,Php,Jquery,Cookies,我有下面的片段,现在发生的是,当我第一次刷新页面时,我通过print\r($\u COOKIE)获得COOKIE当我再次刷新页面时,我可以看到当前的cookie,而不是当我看不到我的受尊敬的cookie时,即结果 jQuery(document).ready(function(e) { jQuery(window).unload(function() { // Remove the cookie jQuery.removeCooki

我有下面的片段,现在发生的是,当我第一次刷新页面时,我通过
print\r($\u COOKIE)获得COOKIE当我再次刷新页面时,我可以看到当前的cookie,而不是当我看不到我的受尊敬的cookie时,即
结果

jQuery(document).ready(function(e) {
        jQuery(window).unload(function() {
            // Remove the cookie
            jQuery.removeCookie("result");
        });
      });
下面是我的JSON成功

   success: function(data)
                    {
                        var server_result = data.result;
                    jQuery('#search-main-area').empty();
                    jQuery.cookie("result", server_result, {expires: 3});
                    var results = jQuery.cookie("result"); // Sample 2
                    jQuery('#search-main-area').append(results);
                    }

你正在调用
.removeCookie()
并想知道为什么你的cookie会消失?@MarcB:我假设
卸载
意味着当这个窗口卸载时,一个新窗口加载了新的URL。@noobie php:
甚至页面重新加载都会首先创建一个卸载事件。
从技术上讲,点击刷新之间没有真正的区别,点击指向你所在页面的链接。两者都将启动http请求。即使该请求只是将页面从缓存中重新加载,它仍然被视为已启动的“转到其他地方”操作,其中“其他地方”是“就在这里”。