473,385 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Application should not be Expire time in ASP.net (using this FormsAuthenticationTicket )

Hi All
I dont want to expire the applicatoion
Once login the application i dont want to expire the application
Presently iam doing using cookies this is not working fine
Please help me out

I was doing like that

System.Web.HttpCookie c = new System.Web.HttpCookie("EXPIREANONYMOUSUSER",
"EXPIRE");
c.Expires = DateTime.Now.AddMonths(6);
Response.Cookies.Add(c);
here "c.Expire" is expiration time

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
txtUserName.Text,
System.DateTime.Now,
c.Expires,
// This is my exprition duration
false,
txtPassword.Text,
FormsAuthentication.FormsCookiePath);
Regards
Karunakara Rao

Nov 19 '05 #1
2 2044
Hi Karunakar,

I have a solution for this. The idea of my solution is simple, session will
timeout only when there are no more requests from that particular user. What
we can do is continously ping the webserver at equal intervals. Let's say you
have your web application's time out set as 20 mins. We will ping the
webserver every 15mins. For this I am using the xmlHTTP object to ping the
webserver.

To implement this
Step 1: Create a dummy page pingreceiver.aspx on the server

Step 2: In the HTML portion of the page copy the following javascript code
Ofcourse, you can move the following code into any script file also and
include that script file in the html portion of the file.

var m_nTimetocheck = 15 * 60000; //This variable defines the period when the
client application has to ping the server.
var m_nTimerID; // A variable to hold the timer handle
var oxmlhttp; // An object to hold the XMLHTTP object.

function onSessionCheck()
{
//Creating an instance of the xmlhttp object.
oxmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

//Initializing the callback method which should be called.
oxmlhttp.onreadystatechange = onSessionCheckReceiver;

//Retrieving the required file
oxmlhttp.Open("GET","pingreceiver.aspx",true);

//Initiating the request
oxmlhttp.send();
}

function onSessionCheckReceiver()
{
if (oxmlhttp.readyState == 4) //if request has be processed
{
//No code for this example
}
}

m_nTimerID = window.setInterval("onSessionCheck();",m_nTimetoch eck);
Step 3: Run the application. You will notice that the application is not
expiring even though there is no activity on the website.

Let me know if this code has been useful for you..
thanks & regards
Saidevakumar

"karunakar" wrote:
Hi All
I dont want to expire the applicatoion
Once login the application i dont want to expire the application
Presently iam doing using cookies this is not working fine
Please help me out

I was doing like that

System.Web.HttpCookie c = new System.Web.HttpCookie("EXPIREANONYMOUSUSER",
"EXPIRE");
c.Expires = DateTime.Now.AddMonths(6);
Response.Cookies.Add(c);
here "c.Expire" is expiration time

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
txtUserName.Text,
System.DateTime.Now,
c.Expires,
// This is my exprition duration
false,
txtPassword.Text,
FormsAuthentication.FormsCookiePath);
Regards
Karunakara Rao

Nov 19 '05 #2
Another possible way would be to have another blank aspx page within
<iframe> periodically refresh itself let's say, 5 minutes.

This will ensure the server won't wipe your user's session. The page will
not flicker because it's within iframe, and the response should be quick
because the aspx page request and response virtually contains nothing.

"saidevakumar" <sa**********@discussions.microsoft.com> ¦b¶l¥ó
news:EA**********************************@microsof t.com ¤¤¼¶¼g...
Hi Karunakar,

I have a solution for this. The idea of my solution is simple, session will timeout only when there are no more requests from that particular user. What we can do is continously ping the webserver at equal intervals. Let's say you have your web application's time out set as 20 mins. We will ping the
webserver every 15mins. For this I am using the xmlHTTP object to ping the
webserver.

To implement this
Step 1: Create a dummy page pingreceiver.aspx on the server

Step 2: In the HTML portion of the page copy the following javascript code
Ofcourse, you can move the following code into any script file also and
include that script file in the html portion of the file.

var m_nTimetocheck = 15 * 60000; //This variable defines the period when the client application has to ping the server.
var m_nTimerID; // A variable to hold the timer handle
var oxmlhttp; // An object to hold the XMLHTTP object.

function onSessionCheck()
{
//Creating an instance of the xmlhttp object.
oxmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

//Initializing the callback method which should be called.
oxmlhttp.onreadystatechange = onSessionCheckReceiver;

//Retrieving the required file
oxmlhttp.Open("GET","pingreceiver.aspx",true);

//Initiating the request
oxmlhttp.send();
}

function onSessionCheckReceiver()
{
if (oxmlhttp.readyState == 4) //if request has be processed
{
//No code for this example
}
}

m_nTimerID = window.setInterval("onSessionCheck();",m_nTimetoch eck);
Step 3: Run the application. You will notice that the application is not
expiring even though there is no activity on the website.

Let me know if this code has been useful for you..
thanks & regards
Saidevakumar

"karunakar" wrote:
Hi All
I dont want to expire the applicatoion
Once login the application i dont want to expire the application
Presently iam doing using cookies this is not working fine
Please help me out

I was doing like that

System.Web.HttpCookie c = new System.Web.HttpCookie("EXPIREANONYMOUSUSER", "EXPIRE");
c.Expires = DateTime.Now.AddMonths(6);
Response.Cookies.Add(c);
here "c.Expire" is expiration time

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
txtUserName.Text,
System.DateTime.Now,
c.Expires,
// This is my exprition duration
false,
txtPassword.Text,
FormsAuthentication.FormsCookiePath);
Regards
Karunakara Rao

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
6
by: Stanley | last post by:
has anyone managed to use cache application block in a web application? thanks stanley
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
1
by: Grey | last post by:
I read from some site to learn the form authentication with AD that it needs to create a FormsAuthenticationTicket to store the group list. I want to that what is the function of...
2
by: Dicky Cheng | last post by:
Hi, I am using absolute expiration to expire my cache object in Cache API. And I set it to expire after 60min. Then I test it, it cache, and everything fine. Then I stop working and lock...
1
by: ad | last post by:
The codes below is copy from msdn about FormsAuthenticationTicket. It add FormsAuthenticationTicket to cookie. How can I add the FormsAuthenticationTicket to URL not to Cookie? ...
1
by: Polani | last post by:
Hi Guys , I am taking DB2 Online backups through TSM API daily. When i check the database configuration parameters , it shows me " Number of database backup verions to maintain"= 12. This is...
5
by: Jono | last post by:
Hi Everyone, Most tutorials I've seen address cookies from the server's perspective, assuming that the client (usually a browser like Internet Explorer) will manage the persistence. I am faced...
5
by: Omer | last post by:
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.