Cookie问题!通过过期日期时出错。 [英] Cookie problem! Getting error when passing the expire date.
问题描述
HI!我继续得到这个错误,我尝试了不同的东西,但我是
不知道如何发送到期日期。
我得到的错误在Firefox 1.5中是
"错误:expires.toGMTString不是函数
---------- ------------------------------------------
我在.js文件和head部分中有这个。
函数Set_Cookie(名称,值,过期,路径,域名,安全){
document.cookie = name +" =" + escape(value)+
((expires)?" ;; expires =" + expires.toGMTString():"")+
((路径) )?" ;; path =" + path:"")+
((domain)?" ;; domain =" + domain:"")+
((安全)?" ;;安全":"");
}
我这样称呼它。
< script type =" text / javascript">
Set_Cookie(" checkpopupwarning"," 1"," Thu,2001年8月2日20: 47:11 UTC"," /");
< / script>
我做错了什么?
Paul
HI! I keep on getting this error and I have tried different things but I am
not sure how to send the expiring date.
The error that I am getting in Firefox 1.5 is
"Error: expires.toGMTString is not a function"
----------------------------------------------------
I have this in a .js file and in the head section.
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTString() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
I am calling it like this.
<script type="text/javascript">
Set_Cookie("checkpopupwarning", "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");
</script>
What Am I doing wrong?
Paul
推荐答案
paul写道:
paul wrote:
错误我进入Firefox 1.5是错误:expires.toGMTString不是一个函数
((expires)?" ;; expires =" + expires。 toGMTString():"")+
[snip] Set_Cookie(" checkp opupwarning"," 1",Thu,2001年8月2日20:47:11 UTC"," /");
我做错了什么?
The error that I am getting in Firefox 1.5 is
"Error: expires.toGMTString is not a function"
( (expires) ? ";expires=" + expires.toGMTString() : "") + [snip] Set_Cookie("checkpopupwarning", "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");
What Am I doing wrong?
toGMTString()方法是属于Date对象的方法。在你的例子中,你传递一个字符串Thu,2 ... etc。字符串没有
有toGMTString()方法。
The toGMTString() method is method belonging to the Date object. In
your example, you are passing a string "Thu, 2 ...etc". Strings don''t
have toGMTString() method.
" paul" < PA *********** @ sympatico.ca>在留言中写道
新闻:1S ******************* @ news20.bellglobal.com ..。
"paul" <pa***********@sympatico.ca> wrote in message
news:1S*******************@news20.bellglobal.com.. .
HI!我继续得到这个错误,我尝试了不同的东西,但我不知道如何发送过期日期。
我在Firefox 1.5中遇到的错误是
错误:expires.toGMTString不是一个函数
我这样称呼它。
< script type =" text / javascript" >
Set_Cookie(" checkpopupwarning"," 1"," Thu,2001年8月2日20:47:11 UTC"," /");
< / script>
我做错了什么?
HI! I keep on getting this error and I have tried different things but I
am not sure how to send the expiring date.
The error that I am getting in Firefox 1.5 is
"Error: expires.toGMTString is not a function"
I am calling it like this.
<script type="text/javascript">
Set_Cookie("checkpopupwarning", "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");
</script>
What Am I doing wrong?
必须为Date对象调用toGMTString而不是字符串文字。
因此应生成您的参数:
var now = new Date(new Date()。setDate(now.getDate()+ 31))// 31天
虽然如果到期时间是在固定天数之后,
而不是特定日期,你的功能看起来会更好接受一个整数
并使用它如上所述来指定th到期日。
-
SC
toGMTString must be called for a Date object not a string literal.
Your parameter should be generated thus:
var now=new Date( new Date().setDate( now.getDate() + 31) ) //31 days
although if the expiry is intended to be after a fixed number of days,
rather
than a specific date, your function would look better accepting an integer
and using it as above to specify the expiry date.
--
S.C.
paul写道:
paul wrote:
我在Firefox 1.5中遇到的错误是
错误:expires.toGMTString不是函数
( (到期)?英寸;期满= QUOT; + expires.toGMTString():"")+
[snip] Set_Cookie(" checkpopupwarning"," 1"," Thu,2001年8月2日20:47:11 UTC"," / );
我做错了什么?
The error that I am getting in Firefox 1.5 is
"Error: expires.toGMTString is not a function"
( (expires) ? ";expires=" + expires.toGMTString() : "") + [snip] Set_Cookie("checkpopupwarning", "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");
What Am I doing wrong?
toGMTString()方法是属于Date对象的方法。在你的例子中,你传递一个字符串Thu,2 ... etc。字符串没有
有toGMTString()方法。
The toGMTString() method is method belonging to the Date object. In
your example, you are passing a string "Thu, 2 ...etc". Strings don''t
have toGMTString() method.
这篇关于Cookie问题!通过过期日期时出错。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!