CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 6/21/2004 7:58:29 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 2 Views: 21 Favorited: 0 Favorite
3 Items, 1 Pages 1 |< << Go >> >|
coolkiwibloke
Asp.Net User
Cookie Expiry6/21/2004 7:58:29 PM

0

I am building a login control using forms authentication and am using the UserDate in the Ticket so therefore need to write the Ticket cookie manually.

I am setting my cookie to expire in 50 years (i.e. persistant :) ) but when I read it back I get the following (i.e. with completely wrong expiry date/time):

Cookie: .ASPXAUTH
Expires: 01/01/0001 00:00:00
Secure: False
Value: D2015AD3DEF04C677547577DCEDED29CADDA533432F2F9EB78C0061273C037B16C889209 4A0471AA49C6AFC5696DEFD420DDFDC6A630F3C2375BB0154AFC9E0DA8D0B3FDE019F19C52E4DB A52CEF16DD

I am using the following code to read the cookie and am wondering if there is something wrong with it?

int loop1, loop2;
HttpCookieCollection MyCookieColl;
HttpCookie MyCookie;

MyCookieColl = Request.Cookies;
// Capture all cookie names into a string array.
String[] arr1 = MyCookieColl.AllKeys;
// Grab individual cookie objects by cookie name.
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{
MyCookie = MyCookieColl[arr1[loop1]];
Content.Text += "Cookie: " + MyCookie.Name + "<br>";
Content.Text += "Expires: " + MyCookie.Expires + "<br>";
Content.Text += "Secure:" + MyCookie.Secure + "<br>";

//Grab all values for single cookie into an object array.
String[] arr2 = MyCookie.Values.AllKeys;
//Loop through cookie Value collection and print all values.
for (loop2 = 0; loop2 < arr2.Length; loop2++)
{
Content.Text += "Value" + loop2 + ": " + Server.HtmlEncode(arr2[loop2]) + "<br>";
}
}





Edited by SomeNewKid. Please post code between <code> and </code> tags.

www.creative-dreaming.com | www.independent-investor.com | www.buffettcup.com | www.thepropertyinvestmentshop.co.uk
master4eva
Asp.Net User
Re: Cookie Expiry6/26/2004 2:10:19 PM

0

Nothing is wrong with you setting the expiration of the cookie. What is not sent (back to you over post back) is the expiration of the cookies "valid" for your site.

For example, if you set the cookies on webpage1.aspx. Then you use the above code for when the browser visits webpage2.aspx, the actual web browser does not submit the expiration dates of the cookies. There are three reasons for this:

1) It reduces the bandwith transfer. (why would you want to learn the expiration of the cookie when you have set it?)

2) On top of the previous reason, setting cookie expirations should not affect how your application is executed -- cookies are only there to persist small amounts of data; not to track it.

3) It is a possible security violation. This is a huge explanation and I really do not feel like walking through it today :-) . Do some reading at the w3c.org and think ABOUT it. This is a minor issue in comparision to the first two reasons.

Cheers,
Justin
-- Justin Lovell
coolkiwibloke
Asp.Net User
Re: Cookie Expiry6/26/2004 2:46:14 PM

0

Thank you! Funny how such an obvious explaination is not explained in an obvious place (Well not obvious to me anyway :) ). I'd just assumed from all the explainations of cookies that I'd read that all properties were available. Cheers.
www.creative-dreaming.com | www.independent-investor.com | www.buffettcup.com | www.thepropertyinvestmentshop.co.uk
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Practical Web technologies Authors: P. K. Yuen, V. Lau, Pages: 903, Published: 2003
JavaScript in 10 simple steps or less Authors: Arman Danesh, Pages: 623, Published: 2003
Web database applications with PHP and MySQL Authors: Hugh E. Williams, David John Lane, Pages: 563, Published: 2002
Meta Tags - Optimising Your Website for Internet Search Engines (Google, Yahoo!, Msn, Altavista, Aol, Alltheweb, Fast, Gigablast, Netscape, Snap, Wise Authors: Samuel Blankson, Pages: 92, Published: 2007

Web:
JavaScript - Cookies Aug 3, 2001 ... Each cookie has an expiry date after which it is trashed. ... The browser sees that the cookie has expired and removes it. ...
JavaScript and Cookies Oct 31, 2002 ... This code sets the logged_in cookie to have an expiry date one ... For example, to use this function to set a cookie with no expiry date: ...
CodeProject: On The Care and Handling of Cookies. Free source code ... Jan 3, 2003 ... You can set a cookie's Expires property using any DateTime value (a ... A commonly accepted "permanent" cookie expiry date is DateTime.Now. ...
Ever tried to set cookie expiry date using JavaScript? - bytes Hi Vince, Based on my experience, we may use JavaScript and Date function to set cookies on client side, for example: ...
Q&A : How do I make cookies expire after a set time period? Depending on how you use the data stored in a cookie, it is often a good idea to make the cookie expire. Since anyone using the browser will have the cookie ...

FormsAuthenticationTicket.Expiration value changing - ng.asp-net ... Cookie Expiry Date: Monday, January 01, 0001 2:00:00 AM ... if (ticket. IsPersistent) { cookie.Expires = ticket.Expiration; } ...
.ASPXAUTH cookie tampering - ng.asp-net-forum.security TIMEOUT:: I added the timeout so that the cookie expires and so that it is a bit more difficult for an attacker to capture the cookie. ...
PrincipalPermission(SecurityAction.Demand, Authenticated=true ... Store the created principal(created from authentication cookie) somewhere ... cookie by default is set with an expiry date of DateTime. ...
Login Control fails with "The user is not associated with a ... forms authentication cookie expiry problem · what changed in system.security. cryptography.rijndaelmanagedtransform.decryptdata? ...
Extending DataGrid with ITemplate - ng.asp-net-forum.windows ... cookie expiry · 2 simple questions from the basics of web server control development · property persistence · getting selected index of dropdownlist ...

Videos:
FORTUNE COOKIE Quick question: do fortune cookies expire? Seriously, I'm wondering...because the cookie in this video really is a year old, and I really did eat ...
snapple and an expired cookie take2 WARNIG VARY RANDOME DONT WATCH IF YOU DONT LIKE. THIS IS THE SAME AS snapple and an expired cookie take1 JUST A RETRY OF ME TRYING TO RECORD MYSELF
Tracy eats an expired cookie. Hilarious. I stuck a 10-year expired cookie in Tracy's mouth while he slept.
What would You rather Do: Watch TV or Make some real Money? Online presentation of the best converting affiliate program on web! We give 60%(27$) to our affiliates, Cookie expires after 6 months, Make your ...
snapple and an expired cookie take1 WARNING VARY RANDOM & BAD FILMING SKILLS + BAD AUDIO this is my camera diary that i started cus i was borde I'm uploading it cus again i am vary ...












hosting asp.net 2.0 + sql server 2005

how do i deal with an unexpected tag when xml is rendered?

how can i set the same appearance like repeater's?

official: asp.net (minimum 2.0) and sql host recommendations.

sorting not working correctly

generating controls inside a server control?

loadviewstate refuses to fire in a custom web control

composite control error?

advanced office editor control in asp.net

**please help: simple custom web server control renders with error during design-time support!

knowing items added/removed in itemtemplate in design mode

persisting children

inherited method calls

custom datagrid - overriding the initializeitem method

simple property - total confusion

security template

event firing problem

bug with hierargrid

button in user control not firing event

asp.net & sql server 2005

license question - trial period???

www.fullcontrol.net

user controls sharing data

header/footer control

page life cycle

calendar control, how to modify the day mon, tue etc.. display

parsechildren and default property?

datagrid and objectdatasource

splitting dotnetnuke and ibuyspy controls?

creating license for asp .net components

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT