一个Cookie - 多页 [英] One Cookie - Multiple Pages

查看:115
本文介绍了一个Cookie - 多页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下cookie:

I am using the following cookie:

var $j = jQuery.noConflict();

$j(document).ready(function(){

   if (document.cookie.indexOf('visited=true') == -1) 
   {
      var thirtyDays = 1000*60*60*24*30;
      var expires = new Date((new Date()).valueOf() + thirtyDays);
      document.cookie = "visited=true;expires=" + expires.toUTCString();
      $j.colorbox({ inline:true, href:"#gallery-nav-instruct"});
   }

});

一切正常,只有一个例外。上述cookie用于在用户第一次访问图库但图库有多个页面时显示说明。会发生什么是用户首次访问该特定页面时看到图库中每个页面的说明。这些指示只要加载一次,当他们访问的画廊,无论他们开始的页面。

Everything works fine with one exception. The above cookie is for displaying instructions the first time a user visit the gallery yet the gallery has multiple pages. What happens is the user sees the instructions for each page in the gallery the first time they visit that specific page. These instructions need to load only once when they visit the gallery no matter which page they start on. How do I go about changing this so it displays only once across my gallery pages?

情侣笔记:

图库包裹在Dreamweaver模板内,Cookie在该模板内。我不能移动cookie的模板以外的几个原因。

The gallery is wrapped inside a Dreamweaver Template and the cookie is inside that template. I cannot move the cookie outside of the template for a few reasons.

此外,我使用托管的CMS,并且不要具有服务器端访问权限,因此必须使用javascript。

Also I use a hosted CMS and I DO NOT have server side access so it must be done using javascript.

推荐答案

添加; path = / 曲奇饼。有关详情,请参阅有关 JavaScript Cookie 的文章。

Add ;path=/ to make your cookie into a site cookie. See this article on JavaScript Cookies for more details.

这篇关于一个Cookie - 多页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆