Re: Cookies Expiring due to different time zones.



Hi Guys,
I will really appreciate, if someone can give me some guidance.
Bye,
Omer.
Omer wrote:
hi Everyone,
I am using ASP.Net 2.0. When user logins, I check the credential and
then made the cookie. My hoster's server is in Arizona region and I am
in Pakistan. I set cookie's expiration time as 4 hours. It works
perfectly fine on my PC and many other PCs which have correct time.
But, if I set date to some old date, user is simply unable to login.
This makes sense as probably cookie timing is not matching. Dilemma is
that many users at home do not have correct time :( and probably thats
why, everyday we get 4-5 mails at support maintaining that they are
unable to login. Can you please tell me what I can do to resolve this
issue. This is the code I am using to create the ticket,

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
this.loginUser1.UserName, DateTime.Now, DateTime.Now.AddHours(4),
this.loginUser1.RememberMeSet, userData);

string cookieStr = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new
HttpCookie(FormsAuthentication.FormsCookieName, cookieStr);
if (this.loginUser1.RememberMeSet)
{
cookie.Expires = ticket.Expiration;
}

cookie.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(cookie);

And this is what I am doing in Global.asax's
Application_AuthenticateRequest function,

if (!(HttpContext.Current.User == null))
{
if (HttpContext.Current.User.Identity.AuthenticationType ==
"Forms")
{
System.Web.Security.FormsIdentity id;
id =
(System.Web.Security.FormsIdentity)HttpContext.Current.User.Identity;
string[] userData = id.Ticket.UserData.Split(new
string[] { "," },

StringSplitOptions.RemoveEmptyEntries);

HttpContext.Current.User = new
System.Security.Principal.GenericPrincipal(id, userData);
}
}

Bye,
Omer

.



Relevant Pages

  • Re: Cookies Expiring due to different time zones.
    ... perfectly fine on my PC and many other PCs which have correct time. ... But, if I set date to some old date, user is simply unable to login. ... This is the code I am using to create the ticket, ... Your problem is that you're using an extremely short time for the cookie expiration. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Cookies Expiring due to different time zones.
    ... perfectly fine on my PC and many other PCs which have correct time. ... But, if I set date to some old date, user is simply unable to login. ... This makes sense as probably cookie timing is not matching. ... this.loginUser1.RememberMeSet, userData); ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Cookies Expiring due to different time zones.
    ... post to your aspx login, sending the cookie's date in a hidden field ... set the aspx login cookie using the date/time in the hidden field ... This is the code I am using to create the ticket, ... Your problem is that you're using an extremely short time for the cookie expiration. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Accessing and displaying SSL web pages and cookies from a windows form
    ... or LoadXML calls to urls on the website in order to get data or post data to ... first redirected to a SSL login page, if a particular cookie is not present, ... cookie is not present instead of getting the data. ... >> the data in the cookie and also not redirect to the login page. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: [PHP] Need secure login
    ... Thanks Justin, actually I was also thinking of the same, but just wanted to ... > c) the user not deleting the cookie ... > Likewise, you can't tie a member to a mac address, or to an IP address. ... Make sure that a user can't login from two different places at ...
    (php.general)

Loading