473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

New to Javascript, help with expiring cookies

1
I get java errors in IE with this cookie, any idea why? Also how do I name the cookie and set it to expire in 20 min. I am not that familiar with expiring cookies. Any help is appreciated.



Expand|Select|Wrap|Line Numbers
  1. function setCookie(name, value, expires, path, domain, secure)
  2. {
  3.     document.cookie= name + "=" + escape(value) +
  4.         ((expires) ? "; expires=" + expires.toGMTString() : "") +
  5.         ((path) ? "; path=" + path : "") +
  6.         ((domain) ? "; domain=" + domain : "") +
  7.         ((secure) ? "; secure" : "");
  8. }
  9.  
  10.  
  11. function getCookie(name)
  12. {
  13.     var dc = document.cookie;
  14.     var prefix = name + "=";
  15.     var begin = dc.indexOf("; " + prefix);
  16.     if (begin == -1)
  17.     {
  18.         begin = dc.indexOf(prefix);
  19.         if (begin != 0) return null;
  20.     }
  21.     else
  22.     {
  23.         begin += 2;
  24.     }
  25.     var end = document.cookie.indexOf(";", begin);
  26.     if (end == -1)
  27.     {
  28.         end = dc.length;
  29.     }
  30.     return unescape(dc.substring(begin + prefix.length, end));
  31. }
  32.  
  33.  
  34. function deleteCookie(name, path, domain)
  35. {
  36.     if (getCookie(name))
  37.     {
  38.         document.cookie = name + "=" + 
  39.             ((path) ? "; path=" + path : "") +
  40.             ((domain) ? "; domain=" + domain : "") +
  41.             "; expires=Thu, 01-Jan-70 00:30:01 GMT";
  42.     }
  43. }
May 28 '07 #1
1 1156
pbmods
5,821 Expert 4TB
Heya, chrisx. Welcome to TSDN!

I get java errors in IE with this cookie, any idea why?
Because you're doing something wrong. If you want a better answer, it might be helpful if you posted WHAT errors you're getting o_O
May 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass...
2
by: Michael | last post by:
I am reading and setting a cookie using JavaScript in the BODY onload and onunload events respectively. This works fine. However when I use ASP to set the cookie under some condition where I...
1
by: John Taylor-Johnston | last post by:
I'm a University academic looking for a proper definition of JavaScript Cookies. http://www.CollegeSherbrooke.qc.ca/languesmodernes/604-HAE_Grammar_Practice/ I'm trying to decipher what...
5
by: Mo | last post by:
I am looking for a JavaScript that will allow me to open a pop-up window "onUnload". The pop-up window should set a cookie on the users computer that expires in 'n' number of days.
0
by: benny | last post by:
Hi, I used following procedure to created the cookies:- FormsAuthentication.RedirectFromLoginPage(IntToStr(BizCustomerID), wchkRememberLogin.Checked); I found that the setting on web.config...
3
by: Mike | last post by:
I have a web application that the forms authentication cookie is not expiring correctly. When I look at the trace information of a newly requested page after the session and forms authentication have...
2
by: Elroyskimms | last post by:
The form has two text fields... one called txtEmail and one called txtPassword. The username is the email address (txtEmail) and the password is txtPassword. Storing cookie using the following...
0
by: robert | last post by:
I have noticed in .net 2 that when authenticating a user, setting the cookie using either redirectfromloginpage or setauthcookie, specifying true for the persistent parameter that the cookie is...
3
by: rh.krish | last post by:
I have a typical ASP.NET 2.0 Forms authentication application which authenticates against Active Directory. I use non-persistent cookie so that the user is NOT remembered across browser sessions....
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.