473,609 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cookie problem! Getting error when passing the expire date.

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.toGMTSt ring is not a function"

----------------------------------------------------
I have this in a .js file and in the head section.

function Set_Cookie(name ,value,expires, path,domain,sec ure) {
document.cookie = name + "=" +escape(value) +
( (expires) ? ";expires=" + expires.toGMTSt ring() : "") +
( (path) ? ";path=" + path : "") +
( (domain) ? ";domain=" + domain : "") +
( (secure) ? ";secure" : "");
}
I am calling it like this.

<script type="text/javascript">
Set_Cookie("che ckpopupwarning" , "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");
</script>

What Am I doing wrong?

Paul
Apr 27 '06 #1
32 4995

paul wrote:
The error that I am getting in Firefox 1.5 is

"Error: expires.toGMTSt ring is not a function"

( (expires) ? ";expires=" + expires.toGMTSt ring() : "") + [snip] Set_Cookie("che ckpopupwarning" , "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");

What Am I doing wrong?


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.

Apr 27 '06 #2

"paul" <pa***********@ sympatico.ca> wrote in message
news:1S******** ***********@new s20.bellglobal. com...
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.toGMTSt ring is not a function"

I am calling it like this.

<script type="text/javascript">
Set_Cookie("che ckpopupwarning" , "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");
</script>

What Am I doing wrong?


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.
Apr 27 '06 #3

paul wrote:
The error that I am getting in Firefox 1.5 is

"Error: expires.toGMTSt ring is not a function"

( (expires) ? ";expires=" + expires.toGMTSt ring() : "") + [snip] Set_Cookie("che ckpopupwarning" , "1", "Thu, 2 Aug 2001 20:47:11 UTC", "/");

What Am I doing wrong?


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.

Apr 27 '06 #4
web.dev wrote:
paul wrote:
The error that I am getting in Firefox 1.5 is

"Error: expires.toGMTSt ring is not a function"

( (expires) ? ";expires=" + expires.toGMTSt ring() : "") +

[snip]
Set_Cookie("che ckpopupwarning" , "1", "Thu, 2 Aug 2001 20:47:11 UTC",
"/");

What Am I doing wrong?


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.


HI! thanks for reponding, hmm, how do I translate the date to numeric? do I
do it like 05, 2 06 2001 20:47:11 ? what about the UTC? do you I use a HEX
value?

Paul
Apr 27 '06 #5
Stephen Chalmers wrote:
"paul" <pa***********@ sympatico.ca> wrote in message
news:1S******** ***********@new s20.bellglobal. com...
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.toGMTSt ring is not a function"

I am calling it like this.

<script type="text/javascript">
Set_Cookie("che ckpopupwarning" , "1", "Thu, 2 Aug 2001 20:47:11 UTC",
"/"); </script>

What Am I doing wrong?


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.


HI! Thanks, I will have to take a different aproach then:

Paul
Apr 27 '06 #6
Stephen Chalmers wrote:
"paul" <pa***********@ sympatico.ca> wrote in message
news:1S******** ***********@new s20.bellglobal. com...
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.toGMTSt ring is not a function"

I am calling it like this.

<script type="text/javascript">
Set_Cookie("che ckpopupwarning" , "1", "Thu, 2 Aug 2001 20:47:11 UTC",
"/"); </script>

What Am I doing wrong?


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.


HI! I am tring somthing else and I get the expired date but I am now having
trouble adding the path

function Set_Cookie(cook ieName,cookieVa lue,nDays,cooki ePath) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime( today.getTime() + 3600000*24*nDay s);
document.cookie = cookieName+"="+ escape(cookieVa lue) +
";expires="+exp ire.toGMTString (); + "path="+cookieP ath";
}

I am using this to call it.

<script type="text/javascript">
Set_Cookie("che ckpopupwarning" , "1", "7", "/");
</script>

I am getting the following as an error:

"Error: unterminated string literal"

I have tried different things but I am still getting this error or
"cookiePath not defined".

Am I adding this together correctly?
Paul
Apr 27 '06 #7

paul wrote:
[snip]
";expires="+exp ire.toGMTString (); + "path="+cookieP ath";


First, remove the semicolon from the call to expire.toGMTStr ing()
Second, you have one too many quotes.

So it should be more like the following:

";expires=" + expire.toGMTStr ing() + "path=" + cookiePath;

Apr 28 '06 #8
web.dev wrote:
paul wrote:
[snip]
";expires="+exp ire.toGMTString (); + "path="+cookieP ath";


First, remove the semicolon from the call to expire.toGMTStr ing()
Second, you have one too many quotes.

So it should be more like the following:

";expires=" + expire.toGMTStr ing() + "path=" + cookiePath;


HI! Great it works, one thing that I dont understand though is why the
forward slash does not need quotes, is it not a string value?

Paul
Apr 28 '06 #9
web.dev wrote:
paul wrote:
[snip]
";expires="+exp ire.toGMTString (); + "path="+cookieP ath";
First, remove the semicolon from the call to expire.toGMTStr ing()
Second, you have one too many quotes.


True.
So it should be more like the following:

";expires=" + expire.toGMTStr ing() + "path=" + cookiePath;


It should be more like

"; expires=" + expire.toGMTStr ing() + "; path=" + cookiePath;
PointedEars
--
The German psychs, the German authorities, the German secret service agents
are [...] fanatics, they are insane and known of persecuting innocent people
and Scientologists. -- "The only real Barbara Schwarz", dsw.scientology ,
<16************ **************@ posting.google. com>
Apr 28 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2409
by: dipesh | last post by:
I am getting error when trying to Add Web Reference in Visual Studio 2005. "Some of the files required for web references are not installed"
3
3486
by: ZMan | last post by:
The following code won't compile with gcc version 3.4.2 (mingw-special). How come? Error: cannot convert `char (*)' to `char**' /**********************************************************/ #include <cstdio> #define MAX_WORD_LEN 80 #define MAX_SIZE 1000
1
2503
by: jonny | last post by:
Went from using Visual Web Develop express to Visual Studio 2005 and getting error when trying to open project. Error message: "One or more projects in the solution could not be loaded for the following reason(s): The project file or web has been moved, renamed or is not on your computer.
0
621
by: =?Utf-8?B?UmF2aQ==?= | last post by:
Hi, I have WCF service and integrated with STS (WS-Federation). The Service exposes 5 endpoints Win, UNT and Federated Windows, Federated UNT and Mex endpoint. My STS Service exposes 3 endpoints WIN, UNT and Mex. I am getting error when I sent a request from a client to WCF Service Fed-Win/ Fed-Unt endpoints. But it is passing for the regular Win and Unt endpoints.
4
4015
by: sumit kale | last post by:
Hi, Can somebody help me resolve my problem ? I am getting error when calculating total using unbound textfiled in subform. I have a main form called purchase_register_master and a subform called purchase_register_details, In sub form i have a unbound textfield called txt_Total_Amount where in i am calculating total amount for different items purchased by giving following code in control source. ContolSource: =Sum() In my main form i...
0
8053
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8557
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8205
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8380
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5504
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1638
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.