Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

track user time logged in

New Here ,
Oct 20, 2009 Oct 20, 2009

I need to build a simple login and have a visitor view a movie clip then log out. I need to store in a database how long the user was logged in using asp. Can anyone help? I can build the login i just need to know how to log users time logged in.

TOPICS
Server side applications
979
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Oct 22, 2009 Oct 22, 2009

Store the current time at login in a session variable:

Session("logintime")=Now

Calculate the elapsed time in seconds:

DateDiff("s",Session("logintime"),now)

Translate
LEGEND ,
Oct 20, 2009 Oct 20, 2009

When they log in, store the date/time in a session variable. When they log out, calculate the difference between the current and stored time, and then insert that into your database.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 20, 2009 Oct 20, 2009

Can u provide a code sample?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 20, 2009 Oct 20, 2009

I don't have a sample. IMO, it's not worth the trouble since most people don't log off anyway --they just leave the site or close the browser -- so the log off script will never run. If you need something more robust you would have to investigate using the global.asa file to code session events. Are you familiar with global.asa ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2009 Oct 21, 2009

No I'm not familiar with it. And on the site the user will have to log out its a corporate intranet and in order to get credit its mandatory. Its for a certification class.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 21, 2009 Oct 21, 2009

Ok, then that should work. What part are you having problems with?

Reading/writing sessions?

SQL insert statement?

Date/time calculations?

What scripting language are you using?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 21, 2009 Oct 21, 2009

The part to code the time stamp for both and the math code

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 22, 2009 Oct 22, 2009
LATEST

Store the current time at login in a session variable:

Session("logintime")=Now

Calculate the elapsed time in seconds:

DateDiff("s",Session("logintime"),now)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines