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

track user time logged in

New Here ,
Oct 20, 2009 Oct 20, 2009

Copy link to clipboard

Copied

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

Views

873
Translate

Report

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)

Votes

Translate
LEGEND ,
Oct 20, 2009 Oct 20, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Report

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

Copy link to clipboard

Copied

Can u provide a code sample?

Votes

Translate

Report

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

Copy link to clipboard

Copied

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 ?

Votes

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Report

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

Copy link to clipboard

Copied

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?

Votes

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Report

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

Copy link to clipboard

Copied

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)

Votes

Translate

Report

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