How to count the active ASP.NET Sessions (SQL Server)?

G

Guest

Hello,
I know that when the SessionState is set to SQL Server (ASP.NET 1.1) these
counters in PerfMon are not valued:
- Sessions Abandoned
- Sessions Active
- Sessions Timed Out
- Sessions Total
Is there another way to get these counters (especially "Sessions Active")
when the SessionState is set to SQL Server?
Thanks in advance!
Joe

--
 
G

Guest

Joe,

Performance counters are only valid for In-Process session state management.
To count active sessions in SQLServer mode you need to create a stored
procedure in the tempdb database that returns the counter:

DECLARE @Now DATETIME

SELECT COUNT(*) AS SessionCount
FROM ASPStateTempSessions
WHERE (Expires < @Now)


hope this helps
--
Milosz Skalecki
MCP, MCAD
 
G

Guest

Milosz,
Yes, thank you very much!

--
Milosz Skalecki said:
Joe,

Performance counters are only valid for In-Process session state management.
To count active sessions in SQLServer mode you need to create a stored
procedure in the tempdb database that returns the counter:

DECLARE @Now DATETIME

SELECT COUNT(*) AS SessionCount
FROM ASPStateTempSessions
WHERE (Expires < @Now)


hope this helps
 
E

Eirikh

Milosz Skalecki and others,

I would rather go:

SELECT COUNT(*) AS SessionCount
FROM [ASPStateTempSessions]
WHERE ([Expires] > GETDATE())

GETDATE() instead of a variable that's not really needed (and only
declared?) and I changed the < to > to actually get all sessions that expires
in the future, and not the ones that have already expired...
 
E

Eirikh

I actually ended up with this:

SELECT COUNT(*) AS SessionCount FROM ASPStateTempSessions WHERE
DATEADD(mi,15,LockDateLocal) > CURRENT_TIMESTAMP

Users active in the last 15 minutes ...

Eirikh said:
Milosz Skalecki and others,

I would rather go:

SELECT COUNT(*) AS SessionCount
FROM [ASPStateTempSessions]
WHERE ([Expires] > GETDATE())

GETDATE() instead of a variable that's not really needed (and only
declared?) and I changed the < to > to actually get all sessions that expires
in the future, and not the ones that have already expired...


Milosz Skalecki said:
Joe,

Performance counters are only valid for In-Process session state management.
To count active sessions in SQLServer mode you need to create a stored
procedure in the tempdb database that returns the counter:

DECLARE @Now DATETIME

SELECT COUNT(*) AS SessionCount
FROM ASPStateTempSessions
WHERE (Expires < @Now)


hope this helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top