Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

Could someone please add an expiry date to this cookie?


Hello,

I am not very good at javascript and I have been trying to set an expiry date to this form cookie for ages - unsuccessfully!

The script alerts users to the fact they have already submitted the form and gives them the date/time they submitted it.  However, the cookie only seems to remember that the form has been submitted for the duration of the session.  If the user logs off or shuts down the browser and tries to submit again, no alert appears. I would like the script to remember for a much longer period (3 months) no matter how many times the user logs off.

The script goes like this ....

<SCRIPT>
var alreadyclicked = "no";
var cookiename = "datesubmitted";

function mySubmit(){
   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "You submitted this form at ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
      ret = confirm(myconfirm);
      if (ret == false){
         return;
      }
   }

   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.myform.submit();
}

</SCRIPT>

Please remember that I am new to javascript and I need spoonfeeding.

Thanks.
0
Gabrielle
Asked:
Gabrielle
  • 19
  • 16
  • 6
  • +3
1 Solution
 
CJ_SCommented:
expirydate = new Date(today.getTime() + (90 * 86400000)); // a year

function setCookie (name,value,expires,path,theDomain,secure) {
   var theCookie = name + "=" + escape (value) +
   ((expires)    ? "; expires=" + expires.toGMTString() : "") +
   ((path)       ? "; path="    + path   : "") +
   ((theDomain)  ? "; domain="  + theDomain : "") +
   ((secure)     ? "; secure"            : "");
   document.cookie = theCookie;
}


Now call it like:
setCookie("mycookiename", "cookievalue", expiredate);

regards,
CJ
0
 
GabrielleAuthor Commented:

Thanks CJ.

I've just tried to put your expiry date script into the original form script and I get an error that says:

for the line:
setCookie ("mycookiename", "cookievalue", expiredate)
expiredate is undefined

I did it like this .... I know this is wrong.  Could you please make it right?

<SCRIPT>

setCookie("mycookiename", "cookievalue", expiredate);


var alreadyclicked = "no";
var cookiename = "datesubmitted2";


function mySubmit(){


   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "SORRY.  You already submitted this form on ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
       ret = confirm(myconfirm);
       if (ret == false)     {
      return
   }
}
   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.cisEvaluation.submit();
}

expirydate = new Date(today.getTime() + (90 * 86400000));

function setCookie (name,value,expires,path,theDomain,secure)
{
  var theCookie = name + "=" + escape (value) +
  ((expires)    ? "; expires=" + expires.toGMTString() : "") +
  ((path)       ? "; path="    + path   : "") +
  ((theDomain)  ? "; domain="  + theDomain : "") +
  ((secure)     ? "; secure"            : "");
  document.cookie = theCookie;
}

</SCRIPT>
0
 
CJ_SCommented:
My typo :-(

setCookie("mycookiename", "cookievalue", expirydate);

e should've been an y...my mistake.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
GabrielleAuthor Commented:

CJ - thanks again for that.

I thought you might have made a typo before and I have already tried the code:

setCookie("datesubmitted", "mydate", expirydate);

... but I still get the same error message.

Have I cut and pasted your code into the right places into the original?



0
 
CJ_SCommented:
Check your browser-cache
0
 
msdixonCommented:
you also can use asp to set the cookie as an option... little easier to work with.
0
 
Dave_GreeneCommented:
setCookie('DiskCookie','passed',ExpireDate,'/');

function setCookie (name,value,expires,path,theDomain,secure)
  {
    var theCookie = name + "=" + escape (value) +
    ((expires)    ? "; expires=" + expires.toGMTString() : "") +
    ((path)       ? "; path="    + path   : "") +
    ((theDomain)  ? "; domain="  + theDomain : "");
    document.cookie = theCookie;
  }
0
 
GabrielleAuthor Commented:

Thanks Dave.

I've added your code to the original script but I still get the same message I got when I tried CJ's.

Maybe I've pasted the code into the wrong place?
I haven't changed any of your code either.  Maybe I should have?

I have added a line from CJ's script too.  Maybe I shouldn't have.

As previously, for the line
setCookie('DiskCookie','passed',ExpireDate,'/');

I get the error message
'ExpireDate' is undefined.

The whole script now looks like this ...


<SCRIPT>

var alreadyclicked = "no";
var cookiename = "datesubmitted";


function mySubmit(){


   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "SORRY.  You already submitted this form on ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
       ret = confirm(myconfirm);
       if (ret == false)     {
      return
   }
}
   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.cisEvaluation.submit();
}

setCookie('DiskCookie','passed',ExpireDate,'/');

ExpireDate = new Date(today.getTime() + (90*86400000));

function setCookie (name,value,expires,path,theDomain,secure)
 {
   var theCookie = name + "=" + escape (value) +
   ((expires)    ? "; expires=" + expires.toGMTString() : "") +
   ((path)       ? "; path="    + path   : "") +
   ((theDomain)  ? "; domain="  + theDomain : "");
   document.cookie = theCookie;
 }

</SCRIPT>

Can anyone see where I'm going wrong?  Please!
0
 
CJ_SCommented:
last part should be:

function setCookie (name,value,expires,path,theDomain,secure)
{
  var theCookie = name + "=" + escape (value) +
  ((expires)    ? "; expires=" + expires.toGMTString() : "") +
  ((path)       ? "; path="    + path   : "") +
  ((theDomain)  ? "; domain="  + theDomain : "");
  document.cookie = theCookie;
}
ExpireDate = new Date(today.getTime() + (90*86400000));
setCookie('DiskCookie','passed',ExpireDate,'/');
0
 
CJ_SCommented:
The order of the calls is incorrect..
0
 
Dave_GreeneCommented:
Yep I suppose you would, sorry I didn't show setting the date variable

ExpireDate = Date();
0
 
GabrielleAuthor Commented:

Thanks again guys
Now for the line,
ExpireDate = new Date(today.getTime() + (90*86400000));

I get the error message,
'today' is undefined.

Any ideas on what I could try next?

The whole script now looks like this ...


<SCRIPT>

var alreadyclicked = "no";
var cookiename = "datesubmitted";


function mySubmit(){


   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "SORRY.  You already submitted this form on ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
       ret = confirm(myconfirm);
       if (ret == false)     {
      return
   }
}
   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.cisEvaluation.submit();
}

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
ExpireDate = new Date(today.getTime() + (90*86400000));
setCookie('DiskCookie','passed',ExpireDate,'/');

</SCRIPT>

0
 
GabrielleAuthor Commented:

Thanks again guys
Now for the line,
ExpireDate = new Date(today.getTime() + (90*86400000));

I get the error message,
'today' is undefined.

Any ideas on what I could try next?

The whole script now looks like this ...


<SCRIPT>

var alreadyclicked = "no";
var cookiename = "datesubmitted";


function mySubmit(){


   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "SORRY.  You already submitted this form on ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
       ret = confirm(myconfirm);
       if (ret == false)     {
      return
   }
}
   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.cisEvaluation.submit();
}

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
ExpireDate = new Date(today.getTime() + (90*86400000));
setCookie('DiskCookie','passed',ExpireDate,'/');

</SCRIPT>

0
 
CJ_SCommented:
today      = new Date();

sorry :-/
0
 
Dave_GreeneCommented:
Pretty sure you do not need the "NEW" keyword...
0
 
GabrielleAuthor Commented:
Hey guys - I've tried two new endings.

Firstly, with this ending ...

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
today = new Date();
ExpireDate = new Date(today.getTime() + (90*86400000));
setCookie('DiskCookie','passed',ExpireDate,'/');

 ... I don't get any error messages!

And - when I try to re-submit the form, the alert message appears giving the correct date/time of submission.

But - if I close and re-open my browser and then try to re-submit, the alert message doesn't appear.

And - if I re-start my pc and try to re-submit the alert doesn't appear either.

With the expiry date set to (today + 3 months), if I submit the form and then close and re-open my browser or re-start my pc and try to re-submit, the alert message should appear, shouldn't it?



Secondly, as I wasn't sure what the "new" keyword was, I tried this ending ....

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
today = Date();
ExpireDate = Date(today.getTime() + (90*86400000));
setCookie('DiskCookie','passed',ExpireDate,'/');

... but, unfortunately, I get the following error message with it.

For the line:
ExpireDate = Date(today.getTime() + (90*86400000));
I get the message:
Object doesn't support this property or method.


What should I try now?
0
 
Dave_GreeneCommented:
As far as the second one, yes you would get the Object error.  this is because when you are dimensioning the variable you are setting it to 'create' a new date like so

today = NEW Date();

When you type

today = Date();

You are just placing the date into the variable today...  which could be a keyword...  need to be careful about that!
0
 
GabrielleAuthor Commented:

Ok Dave - I don't really understand any of that.  Sorry.

Which ending should I continue with?
0
 
Dave_GreeneCommented:
Why don't we just do this

The DateAdd function won't return an invalid date. The following example adds one year to January 31:

NewDate = DateAdd("y", 1, Date())
0
 
GabrielleAuthor Commented:
Dave,

I have now managed to mess up your last suggestion.  I didn't know where to add
NewDate = DateAdd("y", 1, Date())
- so - I hazzarded a guess and changed things a bit.


The ending now goes like this ...

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}

today = new Date();
new Date = DateAdd("y", 1, Date())
ExpireDate = new Date();
setCookie('DiskCookie','passed',ExpireDate,'/');


 ... and the error message I get is the following ...

For the line:
new Date = DateAdd("y", 1, Date())
Error message:
Object Expected


Thank you for being so patient.
0
 
Dave_GreeneCommented:
Ok change these lines

<<
today = new Date();
new Date = DateAdd("y", 1, Date())
ExpireDate = new Date();
>>

to

<<
ExpireDate = DateAdd("y", 1, Date())
>>
0
 
GabrielleAuthor Commented:
Dave,

I've changed that last bit and it now looks like this ....

<<
function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}

ExpireDate = DateAdd("y", 1, Date());
setCookie('DiskCookie','passed',ExpireDate,'/');
>>

... and - for the line:
ExpireDate = DateAdd("y", 1, Date());

I get the error message:
Object Expected

Any ideas?
0
 
GabrielleAuthor Commented:
Guys,

I don't know if this is any help - but - a while ago I got this solution ...

<<
function mySubmit() {
cookiename = "alreadysubmitted"
if (document.cookie.indexOf(cookiename) > -1){
 alert("You can only submit this form once.")
 return false;
} else {
 mydate = new Date();
 mydate.setMonth(mydate.getMonth() + 3)
 document.cookie = cookiename + "=" + mydate;
 return true;
}
}

<form onsubmit="return mySubmit();">

>>

.... which I haven't managed to get to work.

This solution also removes the re-submit option that the orginal script offers.
I would like to remove the re-submit option - but - I thought I'd ask another question and offer up some more points for that once I've got the expiry date issue sorted.
0
 
Dave_GreeneCommented:
Have you dimensioned ExpireDate?

Dim ExpireDate
0
 
GabrielleAuthor Commented:
The last bit of the code is like this now ...

<<
function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
 

ExpireDate = DateAdd("y", 1, Date());
setCookie('DiskCookie','passed',ExpireDate,'/');
Dim ExpireDate();

>>


 ... and for the line:
<input type="button" value="Submit" onClick="mySubmit()" name="button">


I get the error message:
Object Expected

We seem to be going round in circles a bit here.  Is this normal?  This is my first question at Devx and I'm new to javascript.
0
 
Dave_GreeneCommented:
I,m Sorry, wrong scripting language... I've been sending you in the wrong direction...  my apologies!!!

<<

var ExpireDate = new Date()
var expDays = 30;  <--- change this value to extend cookie life
ExpireDate.setTime(ExpireDate.getTime() + (expDays*30*24*60*60*1000));

>>
0
 
GabrielleAuthor Commented:

The last bit of the code is like this now ...

<<

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
 

var ExpireDate = new Date();
var expDays = 90;
ExpireDate.setTime(ExpireDate.getTime() + (expDays*30*24*60*60*1000));



>>



 ... and I don't get any error messages, which makes a nice change!

And - when I try to re-submit the form, I get the correct alert message giving the correct date/time of submission.

But - (and this has happened before) if I close and re-open my browser and try to re-submit the alert message doesn't appear.  The cookie still only seems to last for the duration of the session.

I've looked in my temporary internet files directory to see if anything like our cookie has appeared, and it hasn't.

Thanks again for all your help.
0
 
Dave_GreeneCommented:
Just out of curiousity, you have your browser set to accept cookies, correct?
0
 
GabrielleAuthor Commented:


Yes, I have my browser set to accept cookies.
0
 
Dave_GreeneCommented:
Check your Cache settings...

Tools > Internet Options [General Tab] Settings...

Make sure the settings are set to

"Every visit to the page"

and that you have enough space available for web content...
0
 
GabrielleAuthor Commented:
Dave,

My temporary internet file settings were set to check for newer versions "automatically".  I've now set them to check on "every visit".

But still - when I submit the form and close and re-open my browser and try to re-submit it, no alert message appears and the form is submitted again.

Do you think we are getting any warmer?
0
 
Dave_GreeneCommented:
Just to be certain... this is the code in question.. correct?

<SCRIPT>
var alreadyclicked = "no";
var cookiename = "datesubmitted";

function mySubmit(){
  if (alreadyclicked == "yes"){
     alert("Form already being processed.");  <-- isn't triggered second time around... right?
     return;
0
 
GabrielleAuthor Commented:
Yes - the beginning of the script is as you say.

Here's the whole script again ....

<SCRIPT>

var alreadyclicked = "no";
var cookiename = "datesubmitted";


function mySubmit(){


   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "SORRY.  You already submitted this form on ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
       ret = confirm(myconfirm);
       if (ret == false)     {
      return
   }
}
   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.cisEvaluation.submit();
}

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
 

var ExpireDate = new Date();
var expDays = 90;
ExpireDate.setTime(ExpireDate.getTime() + (expDays*30*24*60*60*1000));

</SCRIPT>

0
 
Dave_GreeneCommented:
Ok, if this is the case then I think it's a logic problem.

<SCRIPT>

var alreadyclicked = "no";   <--Variable set when page accessed

Try addding this variable into the cookie, then you can perform a read of the cookie for yes or no.
0
 
GabrielleAuthor Commented:
Dave,

I've tried to put

var alreadyclicked="no"

into the cookie several times in several different places
without success.  I really don't know what I'm trying to do. I keep getting an "error on page" message and I can't submit anything.

Could you show me where to put it?  Please.
Here's what I've done.  Don't laugh too much.

<SCRIPT>

var alreadyclicked = "no";
var cookiename = "datesubmitted";


function mySubmit(){


   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }
   
   if (alreadyclicked == "no"){
      function setCookie (datesubmitted);
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "SORRY.  You already submitted this form on ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
       ret = confirm(myconfirm);
       if (ret == false)     {
      return
   }
}
   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.cisEvaluation.submit();
}

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
 

var ExpireDate = new Date();
var expDays = 90;
ExpireDate.setTime(ExpireDate.getTime() + (expDays*30*24*60*60*1000));


</SCRIPT>
0
 
Dave_GreeneCommented:
Ok, the first thing you need to do while opening the page is to read from the cookie if it exists.  

If it exists and the value alreadyclicked = yes then you bypass the submit.  

If the cookie's alreadyclicked = no then you can process the submit.  

If the cookie doesn't exist then alreadyclicked = no
0
 
Dave_GreeneCommented:
In other words, you do not set the value in the page, you only set the value in the cookie.  Then to get the value, you read the cookie and put it in a variable.

pseudo code

if submit = true then
   put yes in cookie
end if

if open page then
   look in cookie for alreadyclicked entry
   if entry exists then
      put entry in variable
   else
      alreadyclicked = no
   end
end if
0
 
GabrielleAuthor Commented:
Dave,

I'm still here.  Trying my best to sort this cookie out.

My script now looks like this ....


<SCRIPT>

var alreadyclicked = "no";
var cookiename = "datesubmitted";


function mySubmit(){


   if (alreadyclicked == "yes"){
      alert("Form already being processed.");
      return;
   }
   
   if (alreadyclicked == "no"){
      function setCookie (datesubmitted);
   }

   if (document.cookie.indexOf(cookiename) > -1){
      var mystart =document.cookie.indexOf(cookiename);
      var myend = document.cookie.indexOf(";", mystart);
      if (myend < 0){myend = document.cookie.length;}
      var mydate = document.cookie.substring(mystart + cookiename.length + 1, myend+1);

      var myconfirm = "SORRY.  You already submitted this form on ";
      myconfirm = myconfirm + mydate;
      myconfirm = myconfirm + ". Submit again?"
       ret = confirm(myconfirm);
       if (ret == false)     {
      return
   }

else (alreadyclicked == "no") {


}
   mydate = new Date();
   document.cookie = cookiename + "=" + mydate;
   alreadyclicked = "yes";
   document.cisEvaluation.submit();
}

function setCookie (name,value,expires,path,theDomain,secure)
{
 var theCookie = name + "=" + escape (value) +
 ((expires)    ? "; expires=" + expires.toGMTString() : "") +
 ((path)       ? "; path="    + path   : "") +
 ((theDomain)  ? "; domain="  + theDomain : "");
 document.cookie = theCookie;
}
 

var ExpireDate = new Date();
var expDays = 90;
ExpireDate.setTime(ExpireDate.getTime() + (expDays*30*24*60*60*1000));

}

</SCRIPT>

... but I still get an "Error on page" message.

Do you think it would be worth submitting the question again and offering another
100 points?

- Or - do you think you have nearly cracked it?

0
 
Dave_GreeneCommented:
You didn't make the changes I proposed!

You need to...

<SCRIPT>

var alreadyclicked = "no";  <---Remove this
var cookiename = "datesubmitted";


and add a function to read the cookie contents before you do anything.  Or else you will get this error to oblivion!

Follow the suggestions of my last 2 posts and you will be on your way.  If you want someone to code it for you, just post another question.
0
 
GabrielleAuthor Commented:
Dave,

I don't know how to do what you suggest in your last two points and I need someone to do the coding for me.

If I post it as another question, would you be able to do it?

0
 
Dave_GreeneCommented:
Yes, I could do it, but doesn't that defeat the point of actually learning how things work.  You don't have to give me points, I just want you to figure this thing out. I'm trying to help as much as possible without coding the whole thing for you.  If all you want is code, delete this question and ask a new one... no hard feelings

-Dave
0
 
GabrielleAuthor Commented:
Dave,

I would love to learn how this works - but - at the moment I don't think I'm even at a stage where I understand the points you're trying to help me with.

I think maybe I should go off and do a bit of studying by myself for a bit and then get back to you.  Hopefully then I will understand what you're trying to tell me.

Any ideas on good tutorials/books?

0
 
COBOLdinosaurCommented:
This question has been abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.
<note>
   In the absence of responses, I may recommend DELETE unless it is clear
   to me that it has value as a PAQ.  Silence = you don't care
</note>

Cd&
0
 
COBOLdinosaurCommented:
It is time to clean this abandoned question up.  

I am putting it on a clean up list for CS.

<recommendation>
points to Dave_Greene

</recommendation>

If anyone participating in the Q disagrees with the recommendation,
please leave a comment for the mods.

Cd&
0
 
SpideyModCommented:
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 19
  • 16
  • 6
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now