C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






How do you create and delete a permanent cookie


Posted Date: 20 Jun 2008    Resource Type: Tips    Category: Web Development
Author: Gaurav AgrawalMember Level: Silver    
Rating: Points: 4



Permanent Cookie:-

If we want to make a cookie permanent then we have to set the Expires property of the cookie to maximum value of the datatime class.

Example


HttpCookie cookie = new HttpCookie();
cookie1.Expires = System.DateTime.MaxValue;


Now the cookie will be stored in the client machine for a long time.
System.DateTime.MaxValue retrive the maximum value of the datatime from the user's machine.

Delete a Permanent cookie-->

If we want to delete a permanent cookie then we have to set the Expires property of the cookie to previous date because there is not any method provided by the .Net framework to directly delete a cookie.

Example:==
if we want to delete above permanent cookie then we need to do


cookie1.Expires = System.DateTime.Now.AddDays(-1);


Here we have set the Expires property to previous day.So it will remove from
the client machine automatically.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Deleting permanent cookie  .  Creating permanent cookie  .  Creating and deleting permanent cookie  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Fill the value in session through Javascript
Previous Resource: Difference between Hyperlink and Linkbutton
Return to Discussion Resource Index
Post New Resource
Category: Web Development


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use