Ask a Question related to ASP.NET General, Design and Development.
-
Frederic Gignac #1
Expiration date seems not to work
Hiya all,
My buddy and I got a bug with the expiration date of a cookie. When we
want to look out the expiration date, the only thing we've got, it's
01/01/0001.
As we know, when we want to create a persitant cookie, we have to put
a expiration date, otherwise, it will be a session cookie. So here our
code :
HttpCookie cookie = new HttpCookie(m_propertyID);
cookie.Value = m_property;
if (m_temporaryCookie == false)
{
cookie.Expires = DateTime.MaxValue;
}
HttpContext.Current.Response.Cookies.Add(cookie);
And when we want to see the value :
HttpCookie cookie =
HttpContext.Current.Request.Cookies[m_propertyID];
if ( cookie != null)
{
HttpContext.Current.Response.Write(cookie.Expires) ;
}
With that, we've always got the 01/01/0001. If you have any ideas to
help us, let us know.
Btw, sorry for the english typos :)
Frederic Gignac Guest
-
Disabling Printing, Saving, Editing, andadding an Expiration date to a PDF file using theAcrobat.
Is it possible to disable Printing, Saving, Editing, and add an Expiration date to a PDF file using the Acrobat SDK? -
Query by date doesn't work
I'm using Informix 9.3, If I run the query in Informix it works, when I run the same query in ColdFusion I get a string to date conversion. I'm... -
Cookie Expiration Date
:confused; Can anyone help me figure out how to change the date that my coldfusion server sets for expiration on client housed cookies? I have run... -
SQL/ASP.NET getting DATE to work in query
I'm grabbing today's date with some ASP.net code: Dim Today As Date Today = Microsoft.VisualBasic.Today() I'm then trying to run a SQL query... -
Reala 6 years after expiration date
I just thought some of you might find interesting the following: I had a brick (20 rolls) of Reala 100 speed film in my refrigerator, not the... -
Chris R. Timmons #2
Re: Expiration date seems not to work
[email]fgignac@neomedia.com[/email] (Frederic Gignac) wrote in
news:8878eaae.0307070719.23f5f551@posting.google.c om:
One way to tell the difference would be to set a value in the cookie:> Thank you Chris for the link. Besides I've got a 500 error page,
> the Google cache saves me ;)
>
> After reading it, I'm now aware that we can't do what we will
> attempt to.
>
> We want to know if the cookie is non-persistant or a persistant
> one. So we think to look for the expires value of the cookie to
> let us know if it's a non or a persistant one.
>
> Obviously, this isn't the good method after reading the
> article...
>
> Any suggests to make the difference between the two types of
> cookies ? Is there a method or something that we haven't see yet
> ?
// Persistent cookie.
HttpCookie cookie = new HttpCookie("MyCookie");
cookie.Expires = DateTime.AddDays(10);
cookie.Values["Persistent"] = "true";
cookie.Values["Data"] = "Hello, world!";
HttpContext.Current.Response.Cookies.Add(cookie);
or
// Non-persistent cookie because no expiraton date is set.
// Will be destroyed when the user closes their browser.
HttpCookie cookie = new HttpCookie("MyCookie");
cookie.Values["Persistent"] = "false";
cookie.Values["Data"] = "foo";
HttpContext.Current.Response.Cookies.Add(cookie);
You can use code like this to see if the cookie is persistent or not:
HttpCookieCollection cookies = HttpContext.Current.Request.Cookies;
bool isMyCookiePersistent = false;
if (cookies["MyCookie"] != null)
{
isMyCookiePersistent =
(cookies["MyCookie"].Values["Persistent"] == "true");
}
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
[url]http://www.crtimmonsinc.com/[/url]
Chris R. Timmons Guest
-
Frederic Gignac #3
Re: Expiration date seems not to work
"Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message news:<Xns93B18E888DFABcrtimmonscrtimmonsin@207.46. 248.16>...
>> > One way to tell the difference would be to set a value in the cookie:
> // Persistent cookie.
> HttpCookie cookie = new HttpCookie("MyCookie");
> cookie.Expires = DateTime.AddDays(10);
> cookie.Values["Persistent"] = "true";
> cookie.Values["Data"] = "Hello, world!";
> HttpContext.Current.Response.Cookies.Add(cookie);
>
> or
>
> // Non-persistent cookie because no expiraton date is set.
> // Will be destroyed when the user closes their browser.
> HttpCookie cookie = new HttpCookie("MyCookie");
> cookie.Values["Persistent"] = "false";
> cookie.Values["Data"] = "foo";
> HttpContext.Current.Response.Cookies.Add(cookie);
>
> You can use code like this to see if the cookie is persistent or not:
>
> HttpCookieCollection cookies = HttpContext.Current.Request.Cookies;
> bool isMyCookiePersistent = false;
>
> if (cookies["MyCookie"] != null)
> {
> isMyCookiePersistent =
> (cookies["MyCookie"].Values["Persistent"] == "true");
> }
>
>
> Hope this helps.
>
> Chris.
> -------------
> C.R. Timmons Consulting, Inc.
> [url]http://www.crtimmonsinc.com/[/url]
Thanks again ! It was this solution that we've been thinking last
week, but since a module administrate the cookie, we will have to
modify a hell lot of code. Since we have to give our project within
days, we won't have the time to do all these modifications. For sure,
for next projects, we'll change our module.
Thank you anyway :)
Fred
Frederic Gignac Guest



Reply With Quote

