2 Replies Latest reply on Dec 6, 2012 7:56 AM by Deepika R

    Imp: new session for the same user if  idle for 4 mins. or else throw error

    Deepika R
      Dear All,

      I have a requirement where for security reasons if a session remains idle for 4 mins. or more, it should redirect to login page. This is easy as there is a feature in apex itself under security in application properties. This works fine.

      But I also don't want the users to start two active parallel sessions for the same user, and allow user to login only if the session for the user is idle for 4mins. or more or else display error message that the user has already logged.

      A second in sequence, on submit process for this in page 101 when login button is hit is written for this. It is as follows:

      found boolean := false;
      for x in (SELECT a.apex_user from apex_workspace_activity_log a,apex_workspace_sessions b, (SELECT max(view_date) as maxdate FROM apex_workspace_activity_log where upper(apex_user)=upper(:P101_USERNAME) and APPLICATION_ID=120) maxresults, (SELECT max(session_created) as maxcreate FROM apex_workspace_sessions where upper(user_name)=upper(:P101_USERNAME)) maxsession where b.session_created=maxsession.maxcreate AND b.APEX_SESSION_ID!=:SESSION and upper(b.user_name)=upper(:P101_USERNAME) and b.APEX_SESSION_ID=a.APEX_SESSION_ID and a.seconds_ago<240 AND a.APPLICATION_ID=120 and a.view_date=maxresults.maxdate and rownum=1) loop
      raise_application_error(-20000, 'Already Logged.');
      end loop;
      IF not found THEN
      END IF;

      But for some this reason this does not work as intended. Two users can login parallely.

      When I trace the program, I see that it should catch the parallel user login. But it does not.

      Is it some db cache issue? I don't know.

      Kindly let me know how to fix this. It is crucial for us to achieve this.

      Thanking in advance.