Determining when session expires

I want to be able to track the amount of time that the user spends on my site. I am going to insert a record into a database when the user logs on. I also want to insert a record when the user's session expires either from timing out or closing the browser window or leaving my site. Is it possible to determine when a user's session ends, particularly when it ends via the last two ways.
Thanks!

First, you can use a javax.servlet.http.HttpSessionBindingListener object put into the session as an attribute and implement the valueUnbound() method to do the database update. This will be called when you invalidate the session (unless you remove the attribute manually first).
So the problem is when will the session be invalidated..... There are really 4 things you are looking for:
1) session times out
2) user logs out (assuming you provide a log out link that invalidates the session)
3) browser closes
4) user leaves site (I assume you mean just goes to some other site in the same browser window)
1 and 2 are okay, cuz it invalidates the session and calls the valueUnbound method of the object you create as mentioned above.
For 3 and 4, you can do this in one of 2 ways:
A) Use frames in your web pages and in the top window, you can have a Javascript call some logout page. However, I'm not convinced that this will work in all situations.
B) Have an applet in the pages that does something to keep the connection alive. This requires an applet and a JVM in the client to run it. Probably not a good thing to rely on for public sites.
So really, there is no foolproof or simple way to handle 3 and 4, except to use session timeouts and rely on that.

Similar Messages

  • Generating error page(in jsp) when session expires....

    hello,
    i want to generate error page(in jsp) when session get expires...
    plz help me out.............

    You could do it according to the line BalusC supplied in another topic:
    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=login.jsp">The only thing you gotta change, is the URL, make it:
    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=error.jsp">Create 'error.jsp' and have the message 'Session expired, sorry!' or something printed. If you want to use error.jsp for more than just the session expiration, add a parameter to it:
    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=error.jsp?error=sessionexpired"> Place the following lines in your error.jsp:
    String errormessage = request.getParameter("error");
    if(errormessage.equals("sessionexpired")){
    out.println("Your session has expired, sorry!");
    }else if(errormessage.equals("whatever")){
    // To do code here.
    }

  • Question about redirecting user when session expires

    I have several pages that get and post variables sent to
    them. Is it possible to retain these values when the user's session
    expires? I want to be able to have the user re-log into the system
    and then have them redirected back to the page they were just on
    and preserver the get and post variables so that the data on the
    page can be rendered back to them

    is there anyway to manipulate the headers and store the
    information there and still have it accessible if the session were
    to time out?

  • When-session-expires ?

    hi all,
    i'm trying to find a way to catch when a session expires in oracle database but i don't know how.
    can anyone give suggestions on how i can accomplish this?
    thanks
    allen

    Not sure you can do this and guarantee it, the usual would be to check a column in v$session periodically via a scheduled job , but doesn't PMON kick in and clean it up at intervals, thus making it unsure
    perhaps a logoff trigger to fire ?

  • How to forward automatically when session expires ?

    Hi Techies,
    whenever session expires , I want my struts action to forward to logout page automatically.
    I know we can do it by implementing sessionlistener(session destroyed method).
    But how to forward using action mapping .
    any solution is appreciated.
    Thanks,
    shekar

    HI,
    the other method for this is be prepared from the start
    of making of the project make an action class that
    extends
    org.apache.struts.action.Action
    class
    check all such type of thing ie the session and redirect to global forwards
    logout page
    and other required things
    always extend this ur own made action class
    so that it has all functionality of the struts action
    and ur own vlaidation too

  • Rdirect to another URL when session expires

    public class sessionManager implements HttpSessionListener {
         public void sessionCreated(HttpSessionEvent se) {
         public void sessionDestroyed(HttpSessionEvent se) {
    In this class for the sessionDestroyed() function i want to write RequestDispatcher .. so that i can redirect or forward my request to another URL so that i can delete my object that r present in ServletContext.
    because for requestDispatcher i need to implement HttpServlet
    which overrides service method ( doGet()/doPost()).which receives HttpServletRequest/HttpServletResponse object ...
    Plz let me know if possible .... the main thing is that i want to go to that particular URL for delting my objects
    any Plz let me know

    And if the session expires because the user closed the browser how are you going to redirect him? You can not use the requestDispatcher in the HttpSessionListener because the session will expire because it doesn' have a request.

  • Graceful logout page when session expires.

    Dear SDN community,
       When the session is timed out, the WD application displays a message : "
    The webdynpro application has expired.Restart the application using the application or the following link...". Is there way to catch the session time out and throw a graceful logout page.
    Thanks!

    Hi
    You can make a custom error page as suggested in this link.
    [http://help.sap.com/saphelp_nw2004s/helpdata/en/9a/e74d426332bd30e10000000a155106/frameset.htm]
    Thanks
    Puneet

  • How to disable asking password when session expires

    Hi,
    When the session is timed out, I want application should automatically turned on when I click on alert/message box.
    Please suggest me in what way I can do this.
    Thanks in Advance!!!
    Regards
    Madhu Kumar

    Hi,
    This is an expected behavior and you cannot let the user login again without entering the username/password.
    One possible solution would be increasing the session timeout.
    Note: 269884.1 - How To Fix The Forms Timeout Issue In Oracle Applications 11i
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=269884.1
    Regards,
    Hussein

  • Session expired (timeout) without ADF Security using.

    Hello!
    I have a problem with my application in which i use own security realization without ADF Security using. I realized custom implementation of javax.servlet.http.HttpSessionListener interface, in which i log session creation and expiration events. On WebLogic I realized customDBMS authentification class. Session timeout defined in web.xml (<session-timeout>5</session-timeout>), in weblogic.xml session timeout not define.
    Problem description: when session expired (popup warning displayed before this) and press OK button in popup with session expired warning, I see what no any log about session destroying from my HttpSessionListener implementation, so I cant understand, what session expired and process this event in my servlet filter. So I stay at same page (but without data in tables, coz binding variables in VO queries is not defined). If I am not click OK in the popup and wait about minute, then appear a log message about the destroying the session from my HttpSessionListener implementation. Why is the delay between the appearance of warning session expired and the actual destroying of the session in WebLogic?
    I use JDeveloper 11.1.1.6.0, application deployed in integrated WebLogic 10.3.5.0

    Hi,
    Why is the delay between the appearance of warning session expired and the actual destroying of the session in WebLogic?Because warning is given about 2-3 min before session expire
    That is why
    If I am not click OK in the popup and wait about minute, then appear a log message about the destroying the session from my HttpSessionListener implementation.

  • Session Expired Problem on OAS

    Hi,
    I often got the error message "Session Expired" displayed on my HTML page that serves Java Servlet output after some time.
    I attempted to look through my Servlet source codes but it has no problem. In fact, it runs perfectly well on JavaWebServer2.0.
    This seems to be a OAS problem. I'm using Oracle Application Server 4.0.8.1. I attempted changing the Servlet Cartridge's "Max session idle time" and observe the behaviour. It appears that when "Session Expired" problem happened, my servlet class never get called. OAS simply display a "Session Expired" message on the web page.
    How can I avoid this? How can ask OAS to call my servlet's doGet() to create a new session when it expired?
    Anyone knows how?
    null

    Hi,
    OAS has a limitation of 300 seconds. This value cannot be changed. See the release notes.
    One possible way to get around this is to use the Oracle Supplied Session class and use the time feature in that.
    This a big limitation and I am not sure why Oracle designed the product this way.
    null

  • Hi, I cant login to the facebook app on my iphone 5 ios 6.0.2.  I keep getting an error message saying 'There was an error logging in using single sign on' when im asked to log in again i get a 'session expired' message.  This only started happening yeste

    Hi, I cant login to the facebook app on my iphone 5 ios 6.0.2.  I keep getting an error message saying 'There was an error logging in using single sign on' when im asked to log in again i get a 'session expired' message.  This only started happening yesterday. Anyone else having this problem? Thanks.

    I am having the same problem and took the following steps to mitigate it to no avail.
    1. I deleted the Facebook app on the phone and turned off Facebook in the iPhone's system-wide settings.
    2. I re-enabled Facebook in the iPhone's system-wide settings and reinstalled the Facebook app and logged in again. It worked. For about an hour.
    3. I completely restored the phone to a previous backup (before the problems started) and reenabled Facebook .... reinstalled the app.... and now it works intermittenly. But it hasn't worked in about 12 hours now (just tried a few minutes ago).
    Please advise.

  • Redirect to main jsp when the session expires

    Hi,
    I have a jsp say mainframe.jsp in which I have two frames each having a jsp page say child1.jsp and child2.jsp.
    When the session expires and I when i try do any changes in child2.jsp or child1.jsp, the page redirects to login page and when I login successfully, I am getting redirected to child2.jsp or child1.jsp respectively. But I want it to be redirected to mainframe.jsp.
    Any help is greatly appriciated.
    Thanks in advance.
    Vinod

    I think I am not clear.
    When I try to login after session expiry, I am redirected to child jsp.
    But what I want is that I should be redirected to mainfram.jsp page.
    url in the address shows : ../mainframe.jsp?ID=******
    When my seesion is expired and I try do some manipulation in child1.jsp (which is inside a frame of my mainframe.jsp). it is redirected to login page and from there to child1.jsp instead of mainframe.jsp
    Now the address url shows : ../child1.jsp?ID=********* because of which I am not able to see child2.jsp along with child1.jsp
    What I want : ../mainframe.jsp?ID=********
    this is the code I am using !!
    String destPage = request.getRequestURI();
    response.sendRedirect("../redirect.jsp?dest=" + URLEncoder.encode(destPage));

  • How do you determine when certificates will expire?

    I recently started at a company and my predecessor left no information on licenses and certificates. I need to determine when the certificates expire so I can be prepared to update them with limited downtime.

    If we are talking about the application server SSL certs, then by opening the adminui with https in browser, click on lock icon (In Firefox, More Information -> View Certificate ) as below :
    Check out Expires on field.
    Hope this helps.
    Thanks,
    Wasil

  • Session expired error when creating dataset

    Hi all,
    I am using BI 11.1.1.6.
    I am unable to create a specifically one data set where when I click on OK after giving in the query and dataset name, it says "session expired, please login again". I am able to create other datasets querying from the same schema and tables however this one specifically keeps failing with the same error.
    Is this a bug or am I doing something wrong? The query is as shown below however please note that I am able to put in this query in sqldeveloper and even get data output.
    Thank you.
    SELECT
    proj.project_title,
    proj.project_name,
    rqmt.application_no,
    rqmt.amount_certified,
    rqmt.period_to,
    rqmt.prev_additions,
    rqmt.prev_amount_cert,
    rqmt.prev_deductions,
    rqmt.sub_total_addtns,
    rqmt.sub_total_ddctns,
    rqmt.sum_to_date,
    rqmt.total_additions,
    rqmt.total_balance,
    rqmt.total_deductions,
    rqmt.total_prev_appl,
    rqmt.contractor_claim_amount,
    cnmt.document_number,
    rqmt.orig_contrct_sum,
    rqmt.contractor_commit_total_amount,
    (select sum(this_period) + sum(PREV_APPLCATIONS) from rqdt where rqdt.parent_key = rqmt.master_key and RETENTION_LINE <>1)
    FROM proj,
    rqmt,
    cnmt
    WHERE ( proj.project_name = rqmt.project_name )
    and ( rqmt.cntr_master_key = cnmt.master_key )
    and (( cnmt.document_type = 'INITIALCONTRACTCOMMITMENT' ) )
    AND rqmt.IT_IS_THE_LATEST = 1;

    hey there, sorry i did not but the error stopped after a few days, no idea why and how

  • Session Expired message when click on page menus

    Hi,
    I am getting session expired message when click on page menus. I am getting an error saying that "page you are trying to access is no longer active". Please help me in this.
    Thanks

    When you display the results of you search, is your Servlet writing the HTML out to the screen or is a JSP doing the display?
    If the Servlet is doing the work, and you POST to it, you will get that message everytime in IE, and you will get a "repost data?" popup in Netscape. That is because POST data comes up once on the request, and Netscape (i think) is the only browser that remembers the POSTed parameters. You should be able to quick fix this by changing the initial communication with the Servlet to a GET -OR- by having JSPs do the display of the results.
    Let me know if you need further help or explaination.
    Yoda

Maybe you are looking for