473,788 Members | 2,867 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. }
  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 1178
pbmods
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

0
7073
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
2
5588
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. --------------------------------------------------
1
3180
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 -...
5
1485
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
1609
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" />
3
2364
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...
2
1187
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
0
1738
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...
3
3536
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,...
0
9656
marktang
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...
0
9498
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
10173
jinu1996
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...
1
10110
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
8993
agi2029
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...
1
7517
isladogs
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...
0
6750
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
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
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 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.