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

Please help me create a list of all active sessions?

Can anyone give me a code example of how to use a global array to keep track
of
all active sessions (their sessionid, logontime, etc)?

I need a code example, not a prosa description of what to do..
Anyone..?
Best regards,
Christina
Nov 18 '05 #1
4 1667
Christina,

what you need to do is create a Singleton which has a internal collection or
an arraylist.
on session start. look up the user info you require and populate the
arraylist.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Christina N" <no@mail.please> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Can anyone give me a code example of how to use a global array to keep
track
of
all active sessions (their sessionid, logontime, etc)?

I need a code example, not a prosa description of what to do..
Anyone..?
Best regards,
Christina

Nov 18 '05 #2
Yes, but HOW do I do that? I need a code example.
Can you help me?
Christina

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Christina,

what you need to do is create a Singleton which has a internal collection or an arraylist.
on session start. look up the user info you require and populate the
arraylist.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Christina N" <no@mail.please> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Can anyone give me a code example of how to use a global array to keep
track
of
all active sessions (their sessionid, logontime, etc)?

I need a code example, not a prosa description of what to do..
Anyone..?
Best regards,
Christina


Nov 18 '05 #3
writing a small example.. will post it shortly

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Christina N" <no@mail.com> wrote in message
news:OT**************@TK2MSFTNGP15.phx.gbl...
Yes, but HOW do I do that? I need a code example.
Can you help me?
Christina

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Christina,

what you need to do is create a Singleton which has a internal
collection or
an arraylist.
on session start. look up the user info you require and populate the
arraylist.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Christina N" <no@mail.please> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Can anyone give me a code example of how to use a global array to keep
track
of
all active sessions (their sessionid, logontime, etc)?

I need a code example, not a prosa description of what to do..
Anyone..?
Best regards,
Christina



Nov 18 '05 #4
i will start with a singleton snippet right now.. if you need any further
help you know what to do

using System;
using System.Collections;

public class CUserInfo
{
private string sessionID;
private DataTime sessionTimeStamp;

public CUserInfo(string Sessionid, DateTime SessionTS)
{
sessionID = SessionID;
sessionTimeStamp = SessionTS;
}

public string SessionID
{
get
{
return sessionID;
}
set
{
sessionID = value;
}
}

public DateTime SessionTimeStamp
{
get
{
return sessionTimeStamp;
}
set
{
sessionTimeStamp = value;
}
}
}

public class CSessionManager
{
private static CSessionManager _csmInstance = null;
private ArrayList _alContainer;

private CSessionManager()
{
_alContainer = new ArrayList();
}

public Static CSessionManager GetInstance()
{
if(_csmInstance == null)
{
_csmInstance = new CSessionMananger();
}
return _csmInstance;
}

public Static void AddUserInfo(CUserInfo cui)
{
// do your checks here. like is the info already present ?
_alContainer.Add(cui)
}

public static CUserInfo CurrentUserInfo
{
get
{
string sessionID = this.context.Session.SessionID;
foreach(CUserInfo csi in _alContainer)
{
if(csi.SessionTimeStamp == sessionID)
{
return csi;
break;
}
}
}
set
{
// find the item & update it or remove the item if found
_alContainer.Add(value);
}
}

// Add your public static methods that you wish to call
// say for example to query the SessionManager for count etc
}

Once you create this object you should have the access to same instance
every time you call
CSessionManager myCurrentInstance = CSessionManager.GetInstance();

note that with singleton to get an instance you call the static GetIstance
method and you do not use the new keyword.
Place it in your cache or application object and you should have access
everywhere.

now to add the user
use Global.asax and use the methof Session_Start
here you have access to context object to use it to get session ID

protected void Session_Start(Object sender, EventArgs e)
{
CUserInfo csi = new CUserInfo(this.context.Session.SessionID,
DateTime.Now());
CSessionManager csmanager = CSessionManager.GetInstance();
csmanager.AddUserInfo(csi);

// you should be able to get sessionID (though i never needed to use
session id in this way so am not 100%)
}

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Christina N" <no@mail.com> wrote in message
news:OT**************@TK2MSFTNGP15.phx.gbl...
Yes, but HOW do I do that? I need a code example.
Can you help me?
Christina

"Hermit Dave" <he************@CAPS.AND.DOTS.hotmail.com> wrote in message
news:OR**************@tk2msftngp13.phx.gbl...
Christina,

what you need to do is create a Singleton which has a internal
collection or
an arraylist.
on session start. look up the user info you require and populate the
arraylist.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Christina N" <no@mail.please> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Can anyone give me a code example of how to use a global array to keep
track
of
all active sessions (their sessionid, logontime, etc)?

I need a code example, not a prosa description of what to do..
Anyone..?
Best regards,
Christina



Nov 18 '05 #5

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

Similar topics

0
by: Guy Deprez | last post by:
Hi, i'm having a problem to create indexes. STEP 1 ----------- Connection is OK (you can find the string at the end of the message) Table ("Couleurs") creation is OK STEP 2. Index Creation
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
2
by: Marcio Kleemann | last post by:
Is there a way to get a list of the session id's for all currently active sessions for the application? Thanks
2
by: Lenn | last post by:
Hello, This requirement might seem strange to someone out there, but here it's We need to make sure only certain number of users can be logged in the site at the same time. Is there any way to...
9
by: Laurent Bugnion | last post by:
Hi, I am wondering what is the best way to find out which ASP.NET sessions are still active. Here is the reason: I have a custom control which can upload files. It saves the files in a folder...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
2
by: JoeSep | last post by:
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...
2
by: Krish........... | last post by:
Hi all, How to find out no of active sessions (at a time) in the web server.. I dont think handling Session_start and Session_end events are useful for this. Is there any way to find all current...
2
by: violeta123 | last post by:
I am stuck! Please help It might be difficult to explain the problem via email, but I will try. I have a Win 2003 Enterprise server running with the only purpose of a membership web site...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.