Solved

Record time logged in

Posted on 2011-09-19
8
191 Views
Last Modified: 2012-05-12
Please let me know if there is a way I can record the amount of time a user is logged in on my ASP.NET (C#) website.

Thanks!
0
Comment
Question by:dshrenik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Accepted Solution

by:
navneethegde earned 167 total points
ID: 36564903
0
 

Author Comment

by:dshrenik
ID: 36564908
Can I do this without getting into MySQL? Thanks!
0
 
LVL 16

Assisted Solution

by:disrupt
disrupt earned 167 total points
ID: 36564943
I would use google analytics as it tracks duration as well.

http://www.google.com/analytics/

0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 3

Assisted Solution

by:chandrasekar1
chandrasekar1 earned 166 total points
ID: 36564962
Then you can go with storing the log details in some of the ways below
1.      Storing in XML (not recommend, if the user size is growing in MB’s)
http://www.codeproject.com/KB/XML/ReadWriteSettings.aspx
2.      Storing in SQLite (powerful standalone small DB)
http://www.codeproject.com/KB/cs/SQLiteCSharp.aspx 
If you don’t want to store the user details, but want to track the site visitor’s count, then you can go with Google analytics or other visit counter meter available.
0
 
LVL 15

Expert Comment

by:navneethegde
ID: 36565011
Hi!

Yes just you needd to store the start time in some session variable and at the
Session_End  calculate.

Thanks!
0
 

Author Comment

by:dshrenik
ID: 36565031
@navneethegde:
Could you elaborate a little more. If possible, can you provide some sample code? Thanks!
0
 
LVL 3

Expert Comment

by:chandrasekar1
ID: 36565146
Create the GLOBAL.ASAXin the solution and replace the below code on Session_end event
protected void Session_End(Object sender, EventArgs e)
{
    if (Session["USER"] != "" &&  Session["USER"] != null)
    {
        //Insert the Userdetails to DB/XML
         logdetails(Session["USER"].ToString());

       //empty the User Session
        Session["USER"] = "";
    }
}
0
 
LVL 15

Expert Comment

by:navneethegde
ID: 36565153
Hi!
    void Session_Start(object sender, EventArgs e)
    {
        // Code that runs when a new session is started// You can set when user 's login is Passed successfully.
        Session["myTimeStart"] = DateTime.Now;
    }

    void Session_End(object sender, EventArgs e)
    {
        // Code that runs when a session ends.
        // Note: The Session_End event is raised only when the sessionstate mode
        // is set to InProc in the Web.config file. If session mode is set to StateServer
        // or SQLServer, the event is not raised.
        Session["TotalTime"] = DateTime.Now - DateTime.Parse(Session["myTimeStart"].ToString());
    }

Thanks!
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question