473,322 Members | 1,496 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,322 software developers and data experts.

Storing Session State in SQL Server..Session doesnt Time out,

Iam storing the session state in SQL Server. The Session gets stored in
the SQL Server temp tables ( I can see some values in the two tables),
but the session doesnt seem to timeout.

We have a situation where we have to differentiate between logout and
session expiration and since the Session_End event doesnt get fired for
out-of-proc sessions, I added tthe two functions

public void Application_PreRequestHandlerExecute(Object sender,
EventArgs e)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies["SID"];

if(cookie != null && cookie.Value !=
HttpContext.Current.User.Identity.Name && Request.IsAuthenticated ==
false)
{
HttpContext.Current.Items.Add("SessionExpired",tru e);
}
}
public void Application_PostRequestHandlerExecute(Object sender,
EventArgs e)
{
HttpCookie cookie = new
HttpCookie("SID",HttpContext.Current.User.Identity .Name);
HttpContext.Current.Response.Cookies.Add(cookie);
}

The code above basically sets the a cookie and checks the cookie value
for the each request. If the cookie is stale and the
Request.IsAuthenticated is false then the session is expired.

But the value of Request.IsAuthenticated is never becoming false. and
HttpContext.Current.User.Identity.Name always has the logged in
username value The Session never seems to expire. I have the serivices
ASP.NET state service running om web-server and SQL Server Agent
running on the SQL Server.

Nov 19 '05 #1
2 2453
that behavior is by design

--
Regards,
Alvin Bruney

[Shameless Author Plug]
The Microsoft Office Web Components Black Book with .NET
available at www.lulu.com/owc
------------------------------------------------------------

"jakk" <rj******@gmail.com> wrote in message
news:11**********************@l41g2000cwc.googlegr oups.com...
Iam storing the session state in SQL Server. The Session gets stored in
the SQL Server temp tables ( I can see some values in the two tables),
but the session doesnt seem to timeout.

We have a situation where we have to differentiate between logout and
session expiration and since the Session_End event doesnt get fired for
out-of-proc sessions, I added tthe two functions

public void Application_PreRequestHandlerExecute(Object sender,
EventArgs e)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies["SID"];

if(cookie != null && cookie.Value !=
HttpContext.Current.User.Identity.Name && Request.IsAuthenticated ==
false)
{
HttpContext.Current.Items.Add("SessionExpired",tru e);
}
}
public void Application_PostRequestHandlerExecute(Object sender,
EventArgs e)
{
HttpCookie cookie = new
HttpCookie("SID",HttpContext.Current.User.Identity .Name);
HttpContext.Current.Response.Cookies.Add(cookie);
}

The code above basically sets the a cookie and checks the cookie value
for the each request. If the cookie is stale and the
Request.IsAuthenticated is false then the session is expired.

But the value of Request.IsAuthenticated is never becoming false. and
HttpContext.Current.User.Identity.Name always has the logged in
username value The Session never seems to expire. I have the serivices
ASP.NET state service running om web-server and SQL Server Agent
running on the SQL Server.

Nov 19 '05 #2
Thanks for responding...but how can I make sure that sessions ends
after a specified time and Request.IsAuthenticated becomes false and
HttpContext.Current.User.Identity.Name becomes empty.

Nov 19 '05 #3

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

Similar topics

1
by: shamanthakamani | last post by:
hai system.web.httpexception,unable to make the session state request to the session state server can u help me to fix the above error when i intalled my project again in remote machine after...
5
by: Frank | last post by:
Our system maintains session state using the ASP.NET State Server service. We expect some of our session state objects to be over 85K, which categorizes them to be VLO's (very large objects) in terms...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
0
by: Maciek | last post by:
Hi When I set Session state mode to StateServer (IIS 6.0; windows2003; .NET 2.0) in my application, I have recived this message:...
1
by: Johndoe | last post by:
Hi, I'm building a Web page with a Flash component that post some content to a handler (ashx file). There is a known bug with Flash 8 running on Firefox, whereby Flash will not send cookies (I...
2
by: DC | last post by:
Hi, we are using ASP.Net 1.1 on eight servers with one session state server (the windows 2003 service). Too often we are getting the exception "Unable to make the session state request to the...
0
by: Harry Haller | last post by:
I am running ASP.NET 2 This works: <http://localhost:2063/Client/Default.aspx> This fails: <http://localhost:1472/Admin/Default.aspx> This is all happening on my local machine which is on a...
10
by: B.E.S. | last post by:
Moving to a new development machine. Am getting the following message when trying to run applications that require the state server: --------8<-------------- Unable to make the session state...
1
by: DNB | last post by:
Presently we use InProc session state to session variables in our application. I was just thinking if its is easy to switch from InProc to SQL server session state. As per my undersrtanding we...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.