473,788 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple question about cookies

Joe
Hi,

I’m creating a cookie named “tick” that should expire after 1 day when user
logs in.

TheDomain = ".www.test. com"
ThePath = "/dir1/subdir"
Response.Cookie s("tick")("ID ") = Session("userEm ail")
Response.Cookie s("tick").Expir es = DateAdd("d", 1, Now())
Response.Cookie s("tick").Domai n = TheDomain
Response.Cookie s("tick").Pat h = ThePath

I want to have a logout link. When clicked, I am trying to set the expiry
date of cookie to say 5 days back like this to tell browser that this cookie
has expired and it should remove it.

Response.Cookie s("tick").Expir es = DateAdd("d", -5, Now())

But I noticed that I am not able to change the cookie’s expiry date by above
line. Can someone tell me what mistake I’m making?

Thanks,

Joe

Nov 19 '05 #1
1 988

I tested your code and it does what is exepcted. Once the server sends a
cookie with the expire date in the past it wont send the cookie to the server
the next time.

Don't forget that when the browser requests the logout page it will still
send the cookie. The logout page sends the command to forget the cookie and
_only then_ the browser wont send it next time.

Is that what's confusing you?

Let me know if you have any more questions..

Cheers,
Tom Pester
Hi,

I'm creating a cookie named "tick" that should expire after 1 day when
user logs in.

TheDomain = ".www.test. com"
ThePath = "/dir1/subdir"
Response.Cookie s("tick")("ID ") = Session("userEm ail")
Response.Cookie s("tick").Expir es = DateAdd("d", 1, Now())
Response.Cookie s("tick").Domai n = TheDomain
Response.Cookie s("tick").Pat h = ThePath
I want to have a logout link. When clicked, I am trying to set the
expiry date of cookie to say 5 days back like this to tell browser
that this cookie has expired and it should remove it.

Response.Cookie s("tick").Expir es = DateAdd("d", -5, Now())

But I noticed that I am not able to change the cookie's expiry date by
above line. Can someone tell me what mistake I'm making?

Thanks,

Joe

Nov 19 '05 #2

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

Similar topics

16
2220
by: Sims | last post by:
Hi, I am using setcookies to store one single value. But i was reading http://za2.php.net/manual/en/function.setcookie.php and i noticed that a cookie might not be accepted yet it might return true. So that makes me wonder what the use of the cookies are if i have no way of making sure that it has been properly accepted. What is the point of having cookies if i have to make a backup plan for users that do not accept them? What do you...
1
2670
by: mark leeds | last post by:
i am not a javasript programmer by any stretch but i have been writing a javascript programmer for a friend that does the following : 1) prompts the user for first name, middle name and last name 2) saves the data in a cookie 3) spits the cookie data back out to the respective fields
111
14431
by: Retlak | last post by:
The recommended (on dozens of websites) and effective (works in Netscape, MSIE, Mozilla, probably others) way to detect if a browser has Javascript turned off is to put this in the <head>: <noscript> <meta http-equiv="refresh" content="1;url=http://yourURL/nojscript.html"> </noscript> This redirects to a doc which typically says "You need to enable
0
1035
by: Joe | last post by:
Hi, I’m creating a cookie named “tick” that should expire after 1 day when user logs in. TheDomain = ".www.test.com" ThePath = "/dir1/subdir" Response.Cookies("tick")("ID") = Session("userEmail") Response.Cookies("tick").Expires = DateAdd("d", 1, Now()) Response.Cookies("tick").Domain = TheDomain
4
1304
by: Ivan Demkovitch | last post by:
Hi! From what I understand cookies could be persisted or in-memory. I need to set second one... This code: Response.Cookies.Value = Server.UrlEncode(phpC); Response.Cookies.Path = "/"; Response.Cookies.Expires = DateTime.Now.AddMinutes(1);
1
1115
by: Jeff | last post by:
When is the value of an authentication cookie sent from the browser to the server - when the value is read from the Cookies collection? Or, is it possible that the Cookies collection is populated immediately on the server when a new browser session is created? Thanks!
1
1036
by: Shapper | last post by:
Hello, I need to know how to do 2 things: 1. CREATE a NEW cookie with 2 values: "password" and "user". 2. APPEND 2 new values to an ALLREADY EXISTING cookie. I created a code which is working: Dim cookie As HttpCookie = New HttpCookie("MyCookie") cookie.Values.Add("culture", "pt-PT") cookie.Expires = #01/01/2010#
7
2289
by: abcd | last post by:
I am trying to set up client machine and investigatging which .net components are missing to run aspx page. I have a simple aspx page which just has "hello world" printed.... When I request that page like http://machinename/dir1/hellp.aspx instead of running that page it starts downloding ...whats missing here ....why the aspx engine not running the page....
0
1233
by: Alan Silver | last post by:
Hello, I am having a problem setting and resetting cookies. I'm sure I just doing something really stupid as this is such a basic issue, but I can find any answer. Please can someone help me? The following code is a complete page that demonstrates my problem. If you save this as an .aspx and load it in a browser, it tells you it is creating the cookie. If you reload the page, it tells you it is changing the value. If you reload it...
3
1322
by: Groove | last post by:
Hey guys - hoping you can help me out here. I'm using asp.net 2 (VB) and trying to set and retrieve values from a cookie. I've done this a few times before w/o a problem but I seem to be overlooking something here. I'm even following my previous working examples and I can't see the different. I have a page that will remember the user's settings using a cookie. Ther Calendar Events, recent orders, etc will be displayed or hidden based...
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
9967
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
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 projectplanning, coding, testing, and deploymentwithout 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...
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
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
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.