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,
FormsAuthentica tionTicket ticket = new FormsAuthentica tionTicket(1,
this.loginUser1 .UserName, DateTime.Now, DateTime.Now.Ad dHours(4),
this.loginUser1 .RememberMeSet, userData);
string cookieStr = FormsAuthentica tion.Encrypt(ti cket);
HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, cookieStr);
if (this.loginUser 1.RememberMeSet )
{
cookie.Expires = ticket.Expirati on;
}
cookie.Path = FormsAuthentica tion.FormsCooki ePath;
Response.Cookie s.Add(cookie);
And this is what I am doing in Global.asax's
Application_Aut henticateReques t function,
if (!(HttpContext. Current.User == null))
{
if (HttpContext.Cu rrent.User.Iden tity.Authentica tionType ==
"Forms")
{
System.Web.Secu rity.FormsIdent ity id;
id =
(System.Web.Sec urity.FormsIden tity)HttpContex t.Current.User. Identity;
string[] userData = id.Ticket.UserD ata.Split(new
string[] { "," },
StringSplitOpti ons.RemoveEmpty Entries);
HttpContext.Cur rent.User = new
System.Security .Principal.Gene ricPrincipal(id , userData);
}
}
Bye,
Omer 5 4045
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,
FormsAuthentica tionTicket ticket = new FormsAuthentica tionTicket(1,
this.loginUser1 .UserName, DateTime.Now, DateTime.Now.Ad dHours(4),
this.loginUser1 .RememberMeSet, userData);
string cookieStr = FormsAuthentica tion.Encrypt(ti cket);
HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, cookieStr);
if (this.loginUser 1.RememberMeSet )
{
cookie.Expires = ticket.Expirati on;
}
cookie.Path = FormsAuthentica tion.FormsCooki ePath;
Response.Cookie s.Add(cookie);
And this is what I am doing in Global.asax's
Application_Aut henticateReques t function,
if (!(HttpContext. Current.User == null))
{
if (HttpContext.Cu rrent.User.Iden tity.Authentica tionType ==
"Forms")
{
System.Web.Secu rity.FormsIdent ity id;
id =
(System.Web.Sec urity.FormsIden tity)HttpContex t.Current.User. Identity;
string[] userData = id.Ticket.UserD ata.Split(new
string[] { "," },
StringSplitOpti ons.RemoveEmpty Entries);
HttpContext.Cur rent.User = new
System.Security .Principal.Gene ricPrincipal(id , userData);
}
}
Bye,
Omer
re:
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.
That makes sense, given that users should not
remain authenticated when their tickets have expired.
re:
Can you please tell me what I can do to resolve this
issue. This is the code I am using to create the ticket,
Your code is fine. It works as it should.
Your problem is that you're using an extremely short time for the cookie expiration.
Is there any reason for you not to set the expiration to 25 hours ?
That would overlap all timezones, eliminating the problem.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Omer" <om*******@gmai l.comwrote in message
news:11******** *************@l 12g2000cwl.goog legroups.com...
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,
FormsAuthentica tionTicket ticket = new FormsAuthentica tionTicket(1,
this.loginUser1 .UserName, DateTime.Now, DateTime.Now.Ad dHours(4),
this.loginUser1 .RememberMeSet, userData);
string cookieStr = FormsAuthentica tion.Encrypt(ti cket);
HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, cookieStr);
if (this.loginUser 1.RememberMeSet )
{
cookie.Expires = ticket.Expirati on;
}
cookie.Path = FormsAuthentica tion.FormsCooki ePath;
Response.Cookie s.Add(cookie);
And this is what I am doing in Global.asax's
Application_Aut henticateReques t function,
if (!(HttpContext. Current.User == null))
{
if (HttpContext.Cu rrent.User.Iden tity.Authentica tionType ==
"Forms")
{
System.Web.Secu rity.FormsIdent ity id;
id =
(System.Web.Sec urity.FormsIden tity)HttpContex t.Current.User. Identity;
string[] userData = id.Ticket.UserD ata.Split(new
string[] { "," },
StringSplitOpti ons.RemoveEmpty Entries);
HttpContext.Cur rent.User = new
System.Security .Principal.Gene ricPrincipal(id , userData);
}
}
Bye,
Omer
Actually its not exactly the time zone problem. Problem is that many
users in my country do not really have maintained PCs, which mean that
there is a high possibility that their PC date is not correct. My
cookie is setting time according to my server. If some one tries to
login on 8th December and his PC has the date 20th July then he is
just not able to login. Is there any way I can set cookie expiration
time according to client PC. I am showing a warning on the 'Trouble
Login Page?' but we all know that people take this as a developmnt
fault instead of thinking that this is how technology is supposed to
work. You just can't give this excuse to users :(
Juan T. Llibre wrote:
re:
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.
That makes sense, given that users should not
remain authenticated when their tickets have expired.
re:
Can you please tell me what I can do to resolve this
issue. This is the code I am using to create the ticket,
Your code is fine. It works as it should.
Your problem is that you're using an extremely short time for the cookie expiration.
Is there any reason for you not to set the expiration to 25 hours ?
That would overlap all timezones, eliminating the problem.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Omer" <om*******@gmai l.comwrote in message
news:11******** *************@l 12g2000cwl.goog legroups.com...
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,
FormsAuthentica tionTicket ticket = new FormsAuthentica tionTicket(1,
this.loginUser1 .UserName, DateTime.Now, DateTime.Now.Ad dHours(4),
this.loginUser1 .RememberMeSet, userData);
string cookieStr = FormsAuthentica tion.Encrypt(ti cket);
HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, cookieStr);
if (this.loginUser 1.RememberMeSet )
{
cookie.Expires = ticket.Expirati on;
}
cookie.Path = FormsAuthentica tion.FormsCooki ePath;
Response.Cookie s.Add(cookie);
And this is what I am doing in Global.asax's
Application_Aut henticateReques t function,
if (!(HttpContext. Current.User == null))
{
if (HttpContext.Cu rrent.User.Iden tity.Authentica tionType ==
"Forms")
{
System.Web.Secu rity.FormsIdent ity id;
id =
(System.Web.Sec urity.FormsIden tity)HttpContex t.Current.User. Identity;
string[] userData = id.Ticket.UserD ata.Split(new
string[] { "," },
StringSplitOpti ons.RemoveEmpty Entries);
HttpContext.Cur rent.User = new
System.Security .Principal.Gene ricPrincipal(id , userData);
}
}
Bye,
Omer
Actually its not exactly the time zone problem. Problem is that many
users in my country do not really have maintained PCs, which mean that
there is a high possibility that their PC date is not correct. My
cookie is setting time according to my server. If some one tries to
login on 8th December and his PC has the date 20th July then he is
just not able to login. Is there any way I can set cookie expiration
time according to client PC. I am showing a warning on the 'Trouble
Login Page?' but we all know that people take this as a developmnt
fault instead of thinking that this is how technology is supposed to
work. You just can't give this excuse to users :(
Maybe this:
on the login page, add some javascript function that automatically
fills some hidden input with the current date/time, as reported by the
client PC. Use this date as the basis for your cookie timeout (as an
absolute expiry date).
Hans Kesting
re:
Problem is that many sers in my country do not really have maintained PCs,
which mean that there is a high possibility that their PC date is not correct.
You cannot program to cover all people's stupidities.
re:
Is there any way I can set cookie expiration time according to client PC.
1. set the cookie with javascript in your aspx login page
2. post to your aspx login, sending the cookie's date in a hidden field
3. read the cookie's date/time (in the hidden field) before logging in the user
4. set the aspx login cookie using the date/time in the hidden field
That might get tricky, though.
re:
we all know that people take this as a developmnt fault instead of thinking that
this is how technology is supposed to work. You just can't give this excuse to users
That's not an excuse. Educate your users.
Telling your users that the site needs their clocks set to the correct date is OK.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Omer" <om*******@gmai l.comwrote in message
news:11******** **************@ l12g2000cwl.goo glegroups.com.. .
Actually its not exactly the time zone problem. Problem is that many
users in my country do not really have maintained PCs, which mean that
there is a high possibility that their PC date is not correct. My
cookie is setting time according to my server. If some one tries to
login on 8th December and his PC has the date 20th July then he is
just not able to login. Is there any way I can set cookie expiration
time according to client PC. I am showing a warning on the 'Trouble
Login Page?' but we all know that people take this as a developmnt
fault instead of thinking that this is how technology is supposed to
work. You just can't give this excuse to users :(
Juan T. Llibre wrote:
re:
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.
That makes sense, given that users should not
remain authenticated when their tickets have expired.
re:
Can you please tell me what I can do to resolve this
issue. This is the code I am using to create the ticket,
Your code is fine. It works as it should.
Your problem is that you're using an extremely short time for the cookie expiration.
Is there any reason for you not to set the expiration to 25 hours ?
That would overlap all timezones, eliminating the problem.
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"Omer" <om*******@gmai l.comwrote in message
news:11******** *************@l 12g2000cwl.goog legroups.com...
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,
FormsAuthentica tionTicket ticket = new FormsAuthentica tionTicket(1,
this.loginUser1 .UserName, DateTime.Now, DateTime.Now.Ad dHours(4),
this.loginUser1 .RememberMeSet, userData);
string cookieStr = FormsAuthentica tion.Encrypt(ti cket);
HttpCookie cookie = new
HttpCookie(Form sAuthentication .FormsCookieNam e, cookieStr);
if (this.loginUser 1.RememberMeSet )
{
cookie.Expires = ticket.Expirati on;
}
cookie.Path = FormsAuthentica tion.FormsCooki ePath;
Response.Cookie s.Add(cookie);
And this is what I am doing in Global.asax's
Application_Aut henticateReques t function,
if (!(HttpContext. Current.User == null))
{
if (HttpContext.Cu rrent.User.Iden tity.Authentica tionType ==
"Forms")
{
System.Web.Secu rity.FormsIdent ity id;
id =
(System.Web.Sec urity.FormsIden tity)HttpContex t.Current.User. Identity;
string[] userData = id.Ticket.UserD ata.Split(new
string[] { "," },
StringSplitOpti ons.RemoveEmpty Entries);
HttpContext.Cur rent.User = new
System.Security .Principal.Gene ricPrincipal(id , userData);
}
}
Bye,
Omer
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: windandwaves |
last post by:
Hi Gurus
I am basically sorry that I have to bother you about this. I am a PHP
beginner and I have been studying sessions and cookies over the last few
weeks. I have learned lots, but I am missing the big picture.
Is it like this:
1. user comes to site
2. user does something (e.g. a search) that may be useful later => session
|
by: Brian Burgess |
last post by:
Hi all,
Anyone know if this is possible? If so, on which page would the
cookie be? .. On the page calling a function defined in the include
file?
thanks in advance..
-BB
|
by: benny |
last post by:
Hi,
I used following procedure to created the cookies:-
FormsAuthentication.RedirectFromLoginPage(IntToStr(BizCustomerID),
wchkRememberLogin.Checked);
I found that the setting on web.config :-
<authentication mode="Forms">
<forms loginUrl="CustLogin.aspx" protection="All" name="Customer" path="/"
timeout="60" />
|
by: Jim Kelly |
last post by:
Hi,
I'm having a strange problem with setting a cookie's expiration date. The
relevant code is as follows:
HttpCookie hc = new HttpCookie("MyCookie");
hc.Values.Add("UserName", tbUserName.Text);
hc.Expires = DateTime.Now.AddDays(30);
Response.AppendCookie(hc);
|
by: Sri. |
last post by:
Hi
I am trying to figure out how to test whether my browser cookies are enabled.
I used the code from the following page
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchaspnetcookies101.as
Basically, it tells me to create a cookie and test the cookie from another page. However, in IE 6.0, if I set my privacy setting to a High level so as to block all cookies, the code always returns that the...
| |
by: Sri |
last post by:
Hi
I am trying to figure out how to test whether my browser cookies are enabled.
I used the code from the following page
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchaspnetcookies101.as
Basically, it tells me to create a cookie and test the cookie from another page. However, in IE 6.0, if I set my privacy setting to a High level so as to block all cookies, the code always returns that the...
|
by: Joey Powell |
last post by:
This message was originally posted to the aspnet.security newsgroup,
but no one there has ever heard of this before. That is why I am
posting this message here, so that more people will see it...
On my asp.net application, suddenly the forms authentication cookies
for clients have quit expiring. This results in users being able to
access the site from day to day without having to log in, even if
their
browers are closed and reopened...
|
by: pv_kannan |
last post by:
I recently found out that my authentication cookies are not expiring
even though I have set the persist property to false. As a result,
users are able to access the secure websites with indifferent results.
Any pointers/suggestions would be very appreciated.
Things were running as usual till until recently.
Here are the relevant pieces of code
==========================================
|
by: serge calderara |
last post by:
Dear all,
I try to make some test on how to use basic cookie but get some trouble in
the sens that I was not able to read back previous cretaed cookies.
In page_load event I have the following code :
If Not IsPostBack Then
If Request.Browser.Cookies Then
If Not IsNothing(Request.Cookies("PS")) Then
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |