Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > HELP: Constantly expiring cookie!!! :(

Reply
Thread Tools

HELP: Constantly expiring cookie!!! :(

 
 
VB Programmer
Guest
Posts: n/a
 
      11-03-2003
I have a login page that creates a cookie. The expiration time (in seconds)
is in a string in web.config. The problem is that I have to keep logging
in after only a few minutes. Any ideas? Here's portions of my cookie
code...

Dim ctxMyContext As HttpContext = HttpContext.Current
Dim fatTicket As New FormsAuthenticationTicket( _
1, txtUserName.Text.ToUpper.Trim, DateTime.Now, _
DateTime.Now.AddMinutes(30), False, strUserData)
Dim strCookieValue As String =
FormsAuthentication.Encrypt(fatTicket)
Dim cookieMyCookie As HttpCookie = New
HttpCookie(FormsAuthentication.FormsCookieName)
Dim strReturnUrl As String

' Create custom cookie
With cookieMyCookie
.Path = FormsAuthentication.FormsCookiePath
.Value = strCookieValue
.Expires =
DateTime.Now.AddMinutes(CType(ConfigurationSetting s.AppSettings("CookieExpir
ationMinutes"), Double))
End With
ctxMyContext.Response.Cookies.Add(cookieMyCookie)

Thanks,
Robert



 
Reply With Quote
 
 
 
 
Andre
Guest
Posts: n/a
 
      11-08-2003
If you use an absolute date as a expiration date, this
date is set by the server, in the server's timezone.

Cookie expiration is in a way handle by the client. The
browser decides whether to include the cookie in the
request send to the server. It does so if the expiration
date is ahead of the client date.

If the server is in a different timezone it can be
problematic.







>-----Original Message-----
>I have a login page that creates a cookie. The

expiration time (in seconds)
>is in a string in web.config. The problem is that I

have to keep logging
>in after only a few minutes. Any ideas? Here's portions

of my cookie
>code...
>
> Dim ctxMyContext As HttpContext =

HttpContext.Current
> Dim fatTicket As New FormsAuthenticationTicket

( _
> 1, txtUserName.Text.ToUpper.Trim,

DateTime.Now, _
> DateTime.Now.AddMinutes(30), False,

strUserData)
> Dim strCookieValue As String =
>FormsAuthentication.Encrypt(fatTicket)
> Dim cookieMyCookie As HttpCookie = New
>HttpCookie(FormsAuthentication.FormsCookieName)
> Dim strReturnUrl As String
>
> ' Create custom cookie
> With cookieMyCookie
> .Path =

FormsAuthentication.FormsCookiePath
> .Value = strCookieValue
> .Expires =
>DateTime.Now.AddMinutes(CType

(ConfigurationSettings.AppSettings("CookieExpir
>ationMinutes"), Double))
> End With
> ctxMyContext.Response.Cookies.Add

(cookieMyCookie)
>
>Thanks,
>Robert
>
>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
logging module -> Miss messages if don't flush constantly? How set toflush constantly? Chris Seberino Python 1 08-21-2010 06:31 PM
Main Mode IKE expiring , what's next? matteo_cardelli@yahoo.co.uk Cisco 0 08-20-2005 05:00 PM
Expiring certification James MCSD 2 11-10-2004 10:39 PM
Re: MCSD vb6 - is it worth it? MCSD v6 exams expiring in 2004 Davin MCSD 0 06-30-2003 03:26 PM
Re: MCSD vb6 - is it worth it? MCSD v6 exams expiring in 2004 Cindy Winegarden MCSD 0 06-29-2003 07:42 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57