473,670 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1678
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******** ******@TK2MSFTN GP10.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******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP10.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******** ******@TK2MSFTN GP15.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******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP10.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.Collecti ons;

public class CUserInfo
{
private string sessionID;
private DataTime sessionTimeStam p;

public CUserInfo(strin g Sessionid, DateTime SessionTS)
{
sessionID = SessionID;
sessionTimeStam p = SessionTS;
}

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

public DateTime SessionTimeStam p
{
get
{
return sessionTimeStam p;
}
set
{
sessionTimeStam p = 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 CSessionManange r();
}
return _csmInstance;
}

public Static void AddUserInfo(CUs erInfo cui)
{
// do your checks here. like is the info already present ?
_alContainer.Ad d(cui)
}

public static CUserInfo CurrentUserInfo
{
get
{
string sessionID = this.context.Se ssion.SessionID ;
foreach(CUserIn fo csi in _alContainer)
{
if(csi.SessionT imeStamp == sessionID)
{
return csi;
break;
}
}
}
set
{
// find the item & update it or remove the item if found
_alContainer.Ad d(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 myCurrentInstan ce = 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(O bject sender, EventArgs e)
{
CUserInfo csi = new CUserInfo(this. context.Session .SessionID,
DateTime.Now()) ;
CSessionManager csmanager = CSessionManager .GetInstance();
csmanager.AddUs erInfo(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******** ******@TK2MSFTN GP15.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******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP10.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
2809
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
3296
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 make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
2
2144
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
1796
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 do that in ASP.NET, in web config file or otherwise. Thanks in advance for your help.
9
2298
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 named after the SessionID. At Session_End, I do some cleanup and delete the "session folder". However, if the PC is rebooted before the session times out, the clean up never happens. So what I wanted to do isL: In my CleanUp method, check all...
1
9623
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 and I was wondering if anyone here would be able to give me some tips for young players such as myself, for learning the language. Is this the best Newsgroup for support with JAVA?
2
3550
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 Total Is there another way to get these counters (especially "Sessions Active") when the SessionState is set to SQL Server? Thanks in advance!
2
12141
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 active sessions by using Application object ? Thanx, Krish....
2
3523
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 that uses SQL server 2000 database. I had the site for over 5 years, but the problem started about 6 months ago. At random times (at least I have not found yet any particular time or event when it happens), the Web site Times-out and so the SQL server....
0
8466
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8591
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8659
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7412
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4388
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2799
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1791
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.