Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In login form, I set cookie expiration to 120 minutes. It's working in my local machine. But It's not working at Online Hosting Server. But when I set expiration to 15 seconds or 1 minutes, it's working at Online Hosting Server. If I set to long time, it's only work for 6 minutes. The cookie expiration is no longer than 6 minutes at Online Hosting Server. I use Plesk Web Host Edition. I change session timeout in ASP.NET Settings. But it's still not working. Where do I need to change setting. I did not found the solution in also Help Guide of Plesk.

I set cookie like this


FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, checkUser.UserName, DateTime.Now, DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), true, "");
string encTicket = FormsAuthentication.Encrypt(authTicket);
HttpCookie faCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
Response.Cookies.Add(faCookie);


In Web Config,

<authentication mode="Forms">
<forms name="mitf" loginUrl="~/Account/LogIn" timeout="120" />

<sessionstate timeout="120">

VB.NET
Can anyone help me please...
Posted
Comments
jgakenhe 20-Dec-15 1:15am    
It sounds like they're restarting the app pool or web server a lot. If you restart either of those or make a change to the web.config, it will kill the session. You should create a ticket with the hosting company and see if it continues.

1 solution

Cookie duration is a client based operation, so it's very, very unlikely that it's Cookies that cause the problem - it's possible that a "new" browser may ignore cookie expiration and deleted them early, but it's very unlikely, and doesn't happen with any on the main four.
So it's probably the Session, rather than Cookies.
You need to talk to your hosting company: some (particularly the cheaper end of the market) restrict the Session to a short interval than the standard 20 minutes, in order to maximise available resources. If they do, then generally it doesn't matter what value you try to set, anything longer than the new default will be ignored. They may be able to extend this for you - or move to a different hosting company which doesn't reduce the duration.
 
Share this answer
 
Comments
Member 10732171 20-Dec-15 5:35am    
Yes. Thanks for answering. It's better to ask my hosting provider for this Http Cookie.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900