Link to home
Start Free TrialLog in
Avatar of AidenA
AidenA

asked on

iis7 is it possible to find out how long it has been since someone last accessed a website

Hi,

People are asking me to up my session time to 4 hours so they don't have to keep logging in and out. But, one of the issues for me is I like the flexibility of knowing there is no one on the site so I can make a quick change. And if I set the timeout to 40 mins I can see when all the sessions have ended because session_end is called in the site.

Is there any way to know how long it has been since someone accessed the website, so for instance if it has been an hour or two and it is 6pm in the evening, I can feel comfortable to make a change rather than having to send mails out to every etc etc.

thanks, Aiden
Avatar of sybe
sybe

For the same purpose I use an application variable which is an two-dimensional array. Each active user has its own element in that array with "user_id" and "last-active"

At each request of a user that array is updated.

When I want to know who is online and how long ago he was active, I loop through that array.
Avatar of AidenA

ASKER

can you clarify a bit? how do you do that?

where do you put it in your code? obviously there are lots of actions a user can take so you can't be updating an application variable in each button click for instance... or ajax call? Do you put it in page load then?

Could you provide a bit of your code maybe so I can get a better idea?
ASKER CERTIFIED SOLUTION
Avatar of sybe
sybe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AidenA

ASKER

well i was just thinking... an easy way to do it would be just to check the log files? For instance... it's 12.17 now (where I am)... if I check the log file I can see that the last action was

2011-12-16 12:02:55 xx.xxx.xx.xxx POST /ManualTasks/User.aspx - 80 frstname.surname xx.xxx.xx.xx Mozilla/4.0+

I'm not sure why... but I can see the firstname.surname of the person also. Although I can't think where exactly that's coming from.

So, I guess that solves the issue really? Although thanks for the code I'll keep in mind in case there's something wrong with that method. What do you think?
Are you sure that each log entree is written immediately? Because I've seen machines where the logs are kept in memory until at some point a batch was written.

I still think it is nice to know who is "online" and see that easily in the browser. Suit yourself however.
Avatar of AidenA

ASKER

yeah, i'm not sure, but it seems pretty immediate from what I can see. I'll just do it that way for the moment but may well implement your code at some stage if it looks like it's not working properly

thanks, Aiden