Meassure the duration of a user login/session

Posted on 2006-04-19
Last Modified: 2006-11-18
Hello folks

Im developing a webappliation that people will pay for the time that they use it.

What is the best way to meassure how long time a user is loged in ?

At first I thougth that session_start and session_end would help me, but if the users just closes the browser the session will not be ended until the session time out limit is reached(im well aware that the www is stateless=. Is there any realiable solution on this problem or is there a total different approach to this problem ?

Thanks for any ideas.

Best regards


Question by:holtis
    LVL 15

    Expert Comment

    There is no reliable solution.

    Depending on what the site does you could change your Session timeout from the default 20 minutes to 2 minutes and then when they sign up they have to agree to pay the extra 2 minutes if they close their browser.

    As you are aware it is stateless which makes this type of business plan more difficult to enforce.

    You could write the entire site in something like Macromedia Flash which as far as I am aware is not completely stateless. (I could be wrong though).

    Your other option would be to get the site to call an AJAX control every minute and once that request does not come through for a minute clsoe the session and send the bill


    Author Comment

    Ajax could be a possiblity but how reliable would this be ?

    One approach could be that one set a time out limit to 20 minutes, on each page request you confirm to the billing database that this session is still acitve(could be a field like "lastupdate") and on each page one could integrate a ajax call that would confirm that the session is still active.

    This would mean that when ever the browser is closed we would still know how long the session was active. What would be the main disadvantages of this solution ?

    Can a user some how stop the ajax calls(by using the stop buttom in the webbrowser)?
    LVL 15

    Expert Comment

    If you enforced Javascript to view the page then it shouldbe quite reliable.

    They cannot call stop, however they can process all requests through a personal proxy and stop it there...
    LVL 15

    Expert Comment

    Decent solution offered.

    Author Comment


    Sorry not for replying earlier. None of the ideas really lead to a solution. However this thread can be closed.

    Best regards

    Accepted Solution

    PAQed with no points refunded (of 500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This video discusses moving either the default database or any database to a new volume.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now