473,883 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

New to Javascript, help with expiring cookies

1 New Member
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. }
  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. }
  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 1184
5,821 Recognized Expert Expert
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

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 simple/advanced html forms and how it can be used to override cookie/session
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 want to override the last value set in the onunload event, it has no effect. The next onload still has the old value. Any ideas? The following code simulates the problem I experience. --------------------------------------------------
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 categor(ies) JavaScript cookies fall under, according to Internet Explorer's help.cfm. What I don't understand is where do JavaScript cookies fall under the help.cfm definition. Maybe I'm not reading "their" English properly? (See below.) "Persistent -...
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.
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 :- <authentication mode="Forms"> <forms loginUrl="CustLogin.aspx" protection="All" name="Customer" path="/" timeout="60" />
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 expired the forms authentication cookie is assigned a new value. I am never redirected to the login page after my initial login. If I access the site from http://localhost/myapp instead of myapp.domain.com the cookies expire correctly. The cookie...
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 code: Response.Cookies("Email").Value = txtEMail.Text Response.Cookies("Email").Expires = DateTime.Now.AddDays(30) The cookie is accessed using the following code: txtEMail.Text = Request.Cookies("Email").Value
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 persistent with an expiry time of 30 minutes from now, unless you have specified a timeout attribute in the forms element in the web.config. Quoting from msdn: "timeout: Optional attribute. Specifies the time, in integer minutes, after which...
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. The timeout is set to 10 minutes. Here is the important code snippets that I took from my original code: string roleToCheck = .....; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, member.UserName, DateTime.Now,...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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,...
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...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.