No problem, Vivek if you got busy. After all, everyone's busy in this world. Still there are nice people like you who take some time out of their busy schedule to help people like me.
Now getting back to the main topic, I tried setting the timeout in the web.config file to 50000000 but still doesn't make any difference. The user is forced to login when he opens his browser the very next next day.
This persistent cookie issue has been really bugging me no end. I guess MS has persistent cookies in theory only & not in practical.......
Thanks
RON
*********
If you have an apple & I have an apple & we exchange our apples, then each of us will still have only 1 apple but if you have an idea & I have an idea & we exchange our ideas, then each of us will have 2 ideas
It is working at my end. Let me elaborate how I am testing the same.
I have created 2 pages, Login and Default. In the Login Page, I have this coding:
protected void Page_Load(object sender,
EventArgs e)
{
string Username =
"vivekT";
if (TextBox1.Text ==
"a")
{
HttpCookie cookie =
FormsAuthentication.GetAuthCookie(Username,
true); //true is used to create a persistent cookie
cookie.Expires = DateTime.Now.AddMonths(3);
//DOESN'T WORK
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(Username,
true));//redirect to the originally requested page
}
}
Now even if I change the date on my machine to, let's say, two days ahead, even then I am able to log in (as my expiry value is 5,00,000 minutes, slightly less than a year). So I think it is working if we assume that the expiry value is taken from the config
file and not from the explicit cookie expiry set by us.
Yes, Vivek, you have hit the nail on the head. To ensure that the cookie becomes persistent, the
timeout property of the <forms> tag needs to be set in the
web.config file; the Expires property of the HttpCookie object
shouldn't be assigned any value in the ASPX page otherwise the cookie won't remain persistent.
Finally I managed to see light at the end of the tunnel....all THANKS to
YOU...
Thanks
RON
*********
If you have an apple & I have an apple & we exchange our apples, then each of us will still have only 1 apple but if you have an idea & I have an idea & we exchange our ideas, then each of us will have 2 ideas
Few updates: I was again digging this issue in another thread and got to know that there is a way to custom persist cookie in 2.0 by setting a custom FormsAuthenticationTicket expiry.
Check this post:http://forums.asp.net/thread/1448345.aspx
I have also updated my blog: http://geekswithblogs.net/vivek/archive/2006/10/13/93956.aspx
RON
*********
If you have an apple & I have an apple & we exchange our apples, then each of us will still have only 1 apple but if you have an idea & I have an idea & we exchange our ideas, then each of us will have 2 ideas
Please mark this post as answered so that fellow contributors can avoid wasting their crucial time opening this post again in order to answer it (as it is still showing unanswered).
vivek_iit
All-Star
17776 Points
3186 Posts
MVP
Re: Cookies?
Oct 10, 2006 11:49 AM|LINK
See this post too:
http://forums.asp.net/thread/1347970.aspx
Vivek
Communifire: Social Networking and Business Collaboration Platform
RN5A
Participant
961 Points
406 Posts
Re: Cookies?
Oct 12, 2006 03:26 PM|LINK
Now getting back to the main topic, I tried setting the timeout in the web.config file to 50000000 but still doesn't make any difference. The user is forced to login when he opens his browser the very next next day.
This persistent cookie issue has been really bugging me no end. I guess MS has persistent cookies in theory only & not in practical.......
RON
*********
If you have an apple & I have an apple & we exchange our apples, then each of us will still have only 1 apple but if you have an idea & I have an idea & we exchange our ideas, then each of us will have 2 ideas
vivek_iit
All-Star
17776 Points
3186 Posts
MVP
Re: Cookies?
Oct 13, 2006 06:19 AM|LINK
It is working at my end. Let me elaborate how I am testing the same.
I have created 2 pages, Login and Default. In the Login Page, I have this coding:
protected void Page_Load(object sender, EventArgs e)
{
string Username = "vivekT";
if (TextBox1.Text == "a")
{
HttpCookie cookie = FormsAuthentication.GetAuthCookie(Username, true); //true is used to create a persistent cookie
cookie.Expires = DateTime.Now.AddMonths(3); //DOESN'T WORK
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(Username, true));//redirect to the originally requested page
}
}
My Web.Config setting:
<authentication mode="Forms">
<forms name="Test" loginUrl="Login.aspx" path="/" timeout="500000">
</forms >
</authentication>
<authorization>
<deny users="?" />
</authorization>
Now even if I change the date on my machine to, let's say, two days ahead, even then I am able to log in (as my expiry value is 5,00,000 minutes, slightly less than a year). So I think it is working if we assume that the expiry value is taken from the config file and not from the explicit cookie expiry set by us.
Let me know if this is not the case with you.
Vivek
Communifire: Social Networking and Business Collaboration Platform
RN5A
Participant
961 Points
406 Posts
Re: Cookies?
Oct 13, 2006 03:18 PM|LINK
Finally I managed to see light at the end of the tunnel....all THANKS to YOU...
RON
*********
If you have an apple & I have an apple & we exchange our apples, then each of us will still have only 1 apple but if you have an idea & I have an idea & we exchange our ideas, then each of us will have 2 ideas
vivek_iit
All-Star
17776 Points
3186 Posts
MVP
Re: Cookies?
Nov 01, 2006 06:45 PM|LINK
Hi,
Few updates: I was again digging this issue in another thread and got to know that there is a way to custom persist cookie in 2.0 by setting a custom FormsAuthenticationTicket expiry.
Check this post:http://forums.asp.net/thread/1448345.aspx
I have also updated my blog: http://geekswithblogs.net/vivek/archive/2006/10/13/93956.aspx
Regards,
Vivek
Communifire: Social Networking and Business Collaboration Platform
RN5A
Participant
961 Points
406 Posts
Re: Cookies?
Nov 02, 2006 06:44 PM|LINK
RON
*********
If you have an apple & I have an apple & we exchange our apples, then each of us will still have only 1 apple but if you have an idea & I have an idea & we exchange our ideas, then each of us will have 2 ideas
vivek_iit
All-Star
17776 Points
3186 Posts
MVP
Re: Cookies?
Nov 03, 2006 04:02 PM|LINK
Hello,
Please mark this post as answered so that fellow contributors can avoid wasting their crucial time opening this post again in order to answer it (as it is still showing unanswered).
Thanks,
Vivek
Communifire: Social Networking and Business Collaboration Platform