<authentication mode="Forms">
<forms name="SignIn" loginUrl="~/login.aspx" timeout="9999999" slidingExpiration="true" defaultUrl="~/Default.aspx"/>
</authentication>
This will automatically logout my logged in page with in 1 or two minutes ....
I want my session will not terminated automatically until i logout....
how to do this in web.config ?
Here is a very nice and simple technique, Reloading an image time to time keeps session live. A random number at the end if the image force it to load it again. If the image did not trigger the session, then you can change it with a handler that return the same image.
<img id="keepAliveIMG" width="1" height="1" src="/img/ui/spacer.gif?" alt="" />
<script language="javascript" type="text/javascript">
var myImg = document.getElementById("keepAliveIMG");
if (myImg){
window.setInterval(function(){
myImg.src = myImg.src.replace(/\?.*$/, '?' + Math.random());
}, 6000);
}
</script>
I Think you should use cookies. I prefer using this method:
After user clicks login button:
FormsAuthentication.SetAuthCookie(userName, True)
When persistence cookie is set to True, a cookie is created so user will stay logged in even if he closes his session.
My web.config is like:
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
and everything works fine. In sample above the user will stay logged in for 2880 minutes.
Have a look at these links:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.