How to set session timeout per user

Hi,
Ho do I set the session timeout per User in the
Application.cfm File??
I tried using
<cfif SESSION.UID EQ 1>
<CFAPPLICATION NAME="appControl" SESSIONMANAGEMENT="Yes"
sessiontimeout="#CreateTimeSpan(0,0,20,0)#">
</cfelse>
<CFAPPLICATION NAME="appControl" SESSIONMANAGEMENT="Yes"
sessiontimeout="#CreateTimeSpan(1,0,0,0)#">
</cfif>
But this didnt work because the cfapplication seems to have
to be at the top before I call the variable SESSION.UID which
I set on my login page..
Someone know how to do this??
Regards
Martin

Martin,
Your code example cannot work because the "session" scope
doesn't exist until your application scope is defined. So you have
to handle this manually. Here's how you can get it done. First,
define your application to the maximum sessiontimeout you want to
have.
<CFAPPLICATION NAME="appControl" SESSIONMANAGEMENT="Yes"
SESSIONTIMEOUT="#CreateTimeSpan(1,0,0,0)#">
Then, I don't know how you are doing your login
authentication but when you have authenticated the user, you need
to define the userid and the most recent activity in the session.
Also determine your timeout value based on the userid. See example:
<CFIF IS_AUTHENTICATED>
<CFSET session.user.uid = form.userid>
<CFSET session.user.most_recent_activity = now()>
<CFIF session.user.id eq 1>
<CFSET session.user.timeout_mins = 20>
<CFELSE>
<CFSET session.user.timeout_mins = 1440>
</CFIF>
</CFIF>
Now, all you have to do is check whether the user has been
idle for too long and kill the session by purging all session
variables. For example:
<!--- if user id is defined, this means user is logged in
--->
<CFIF structKeyExists(session, "user") and
structKeyExists(session.user, "id")>
<!--- check if timeout has expired --->
<CFIF datediff("n", session.user.most_recent_activity,
now()) gt session.user.timeout_mins>
<!--- timeout has expired, kill the session and log the
user out --->
<CFSET StructClear(session)>
<!--- insert your logout code here --->
<CFELSE>
<!--- user hasn't timed out, so reset the most recent
activity to now --->
<CFSET session.user.most_recent_activity = now()>
</CFIF>
</CFIF>

Similar Messages

  • Iplanet 4.1 - How to set session timeout for a specific application

    Hi everyone,
    I have a Iplanet 4.1 old web instance running on Solaris 8. We are using this web instance to connect to few application instances running on Websphere 3.5. We have upgraded most of our web/app to higher version except this.
    One of the websphere applications need more session timeout. (Which I fuguredout not possible to do on Websphere).
    How do I achieve this on Iplanet 4.1.
    NOTE: I referred to Iplanet 6.x where we can achieve this by updating web-app.xml timeOut value per URI. I do not find web-app.xml under v4.1
    Thanks in advance,

    Sorry to say that we can't help here. WS4.1 is obsolete a long time ago.
    As you mentioned that you should use WS6.1SPx or WS7.0 for your production and get support.

  • Setting session timeout in OracleWeblogic Server

    Hi All,
    I have doubt in setting session time out in Oracle WLS server 12c. Please suggest,
    There are two ways as i know editing the below files.
    1) weblogic.xml
    2) web.xml
    But when I open the weblogic.xml it has the below code, if we edit the value in
    <timeout-secs>3600</timeout-secs>
    the value implied for the admin console only as i know, the admin console will ask the user to re-login if the session is idle for morethan 6 mins.
    But If there is an application deployed like a bank.war file and customer is accessing the application. I want to set the user session time out to 2 mins i.e 120 seconds. How to set this in the server level ?
    Oracle Webogic server level ?
    <session-descriptor>
        <timeout-secs>3600</timeout-secs>
        <invalidation-interval-secs>60</invalidation-interval-secs>
        <cookie-name>ADMINCONSOLESESSION</cookie-name>
        <cookie-max-age-secs>-1</cookie-max-age-secs>
        <url-rewriting-enabled>false</url-rewriting-enabled>
    </session-descriptor>
    In the default web,xml  there is no param called timeout..
    Thanks
    Venkat

    Hello Venkat,
    I have implemented the same in my Application(OBIEE).Check it may helpful for you.
    Sasi Nagireddy: HOW TO CONFIGURE SESSION TIMEOUT IN OBIEE-11G..
    Thanks,
    Sasi Nagireddy..

  • Sso session timeout per partner application

    Hello,
    I was just wondering if it is possible to configure SSO session timeouts per partner application? I'm looking to log out users of a particular application after 15 minutes, but don't want this change to affect any of my other SSO enabled applications. Is this possible?
    Thanks,

    Hi,
    I do not think so, you can not specify specail parameter for one application in SSO.
    Why because SSO is one component (within your Infra) through which you logon different apps.
    Another solution may be it will expensive is that you 'll need to use different infra for this specific application.
    Regards,
    Hamdy

  • How do set operation timeout in tomcat server?

    hi all
    suppose i have one endless loop program(jsp) that program run under tomcat server,
    so it's keep on runing in tomcat server.
    i want, after some time the server send error message like operation timeout.
    how do set operation timeout in tomcat server?
    if anybody know help me.
    my mail id [email protected]

    Well, the server.xml file has connection time outs, but that is for idle time, I think... I'm not sure what would happen in a loop... , especially if you are sending some data back to the client in each iteration. Generally you shouldn't be starting a loop that will really run forever. Maybe have some type of counter to break out if something hasn't occurred within x iterations, or create a separate thread that can sleep for x seconds and set a flag to break the loop after that time.

  • How to make session invalid when user refresh the page?

    How to make session invalid when user refresh the page?

    I have a <form> in a JSP file that has another JSP file as an action.
    I have main.jsp that has <form> with action.jsp file as an action.
    Now when I submit the <form>, request forwarded to action.jsp and it will take the action. But this file is taking so long, hence user refresh the page again and again, hence duplicate request processing is occuring.
    I want to prevent this.

  • Hi I have two questions. I am using NAS 4.1 and was wondering is it possible to set a different session timeout for different users? How is the session timeout set? Thanks, YS

     

    <i>I am using NAS 4.1 and was wondering is it possible to set a different session timeout for different users?</i>
    Um, there is no such thing as NAS4.1.
    I'm assuming that you mean NAS4.0 (maybe NAS4.0sp1?). If so, then the session timeouts are specified in the session section of the NTV configuration files.
    AFAIK, you can specify session timeouts on a per user basis.

  • How to set HttpURLConnection timeout while reading a stream?

    I want it got time out if the connection if lose while i read a stream from URL
    try {
         int timeout = 700;
         HttpURLConnection connection = (HttpURLConnection) downloadURl.openConnection();
         connection.setConnectTimeout(timeout);
         connection.setRequestProperty("Range","bytes=" + downloaded + "-");
         connection.connect();
         if (connection.getResponseCode() / 100 != 2) {
              error();
         int contentLength = connection.getContentLength();
         if (contentLength < 1) {
              error();
         if (status == DOWNLOADING){
              if (size == -1) {
                   size = contentLength;
              file = new RandomAccessFile(saveTmpName+".tmp", "rw");
              file.seek(downloaded);
         byte buffer[];
         stream = connection.getInputStream();
    connection.setReadTimeout(timeout);
         while (status == DOWNLOADING) { 
              if (size - downloaded > MAX_BUFFER_SIZE) {
                   buffer = new byte[MAX_BUFFER_SIZE];
              } else {
                   buffer = new byte[(int)(size - downloaded)];
              int read = stream.read(buffer); // how to set timeout while it is reading stream
              if (read <= 0)
                   break;
              file.write(buffer, 0, read);
              downloaded += read;
         if (status == DOWNLOADING) {
              status = COMPLETE;
    } catch (SocketTimeoutException  e) {
         error();
    } catch (IllegalArgumentException e) {
         error();
    } catch (Exception e) {
         error();
    } finally {
         if (file != null) {
              try {
                   file.close();
              } catch (Exception e) {}
         if (stream != null) {
              try {
                   stream.close();
              } catch (Exception e) {}
    }I try to set "setReadTimeout()" but is still not through timeout Exception

    ejp wrote:
    Because, there's no FTP client command that allows to do such thing.Socket.setSoTimeout().I agree with you on this one but the OP is talking about the FTPClient API from Apache.
    To the OP,
    BTW, I have reread the Javadoc about the [*API*|http://commons.apache.org/net/api/org/apache/commons/net/ftp/FTPClient.html] : indeed, there's no setTimeout method, but there is a setDataTimeout method : +Sets the timeout in milliseconds to use when reading from the data connection+ .

  • How to set session attributes in a bean?

    How do I set a session attribute in a server-side bean?
    I'm not sure if I asked the question the right way. What I meant is, while it's easy to set session attributes in a JSP page (session.setAttribute("sessionname", "sessionvalue")), I'd want to set such an attribute within a server-side bean defined in this web application. But what is the syntax for doing it?

    Here a simple bean that stores something in the session and retrieves something from it.
    import javax.servlet.http.HttpSession;
    public class TestBean {
      private String value;
      public void doSomething(HttpSession session, int a, int b) {
        if (a+b > 0) {
          session.setAttribute("ab",Boolean.TRUE);
        } else {
          session.setAttribute("ab",Boolean.FALSE);
      public void init(HttpSession session) {
        if (session != null) {
          Boolean b = (Boolean)session.getAttribute("ab");
          if (b == Boolean.TRUE) {
            value = "a + b is greater than zero";
          } else {
            value = "a + b is not greater than zero";
        } else {
          value = "no session";
      public String getValue() {
        return value;
    }In your JSP, use something along the lines of :
    <%
      TestBean bean = new TestBean();
      bean.init(session);
      bean.doSomething(session,1,2);
    %>If your bean only lives during one request, you can pass the session to the constructor, which stores it in a private variable. This saves passing the session each time.
    Hope this helps,
    --Arnout                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Setting Session Timeout for HANA Cloud Portal

    Hi all,
    is there any way for setting the session timeout period on HANA cloud Portal?
    If not, what is the predefined session timeout?
    Thank you in advance.
    Silvia Grabmann

    Hi Silvia,
    Session timeout is 20 minutes and cannot be changed. In fact it is configured at the platform level.
    Regards,
    Ifat.

  • How to set Password for Xellerate user in OIM

    I am using recon API's and creating Xellerate user, unfortunately the recon is not accepting USR_PASSWORD which is the field name defined in OIM
    Can somebody please let me know how to set this password for Xellerate user??
    Thank you in advance for your response. (this is go-live issue you know what that means :-)

    Hi,
    If you are doing reconciliation and trying to reconcile the password as well. Then you must map the Resource Object attribute for the password field to the 'Identity' field of OIM. You can find this field in the 'Reconciliation Field Mappings' section for Xellerate User. Just map the field which you want to be set as OIM user password in the section and you are done.

  • How to set password entered by user in the custom self registration app?

    Hi All,
    I am trying to create a customized self registration page on the portal logon page using Webdynpro JAVA application. Now the problem I am facing is that I am not able to identify how to set the initial password for the user in the portal that is entered by the user while registering through the application.
    I am using the object as:
    IUserFactory userFact = UMFactory.getUserFactory();
    IUserMaint userMaint = userFact.newUser(user);
    I am able to set different parameters such as First Name,Last Name, User Id, Email Id, etc but not the password.
    Any pointers will be highly appreciated.
    Thanks in Advance.
    Regards.
    Rajat

    Hi Rajat Jain,
    Try the below code.
    IUserAccountFactory mAccountFact = UMFactory.getUserAccountFactory();
    IUserAccount userAccount =mAccountFact.getUserAccountByLogonId(login); // Provide login
    IUserAccount muserAccount = mAccountFact.getMutableUserAccount(userAccount.getUniqueID());
    muserAccount.setPassword(oldPassword.trim(), confirmPassword.trim());
    muserAccount.save();
    muserAccount.commit();
    Regards,
    VJR.

  • How to set a password's user in active directorywith jndi?

    hi,
    please, i want to see how to set the password of a user, and i want to ask about ssl if i must use it if want to change the password, please can you give a code example.
    thank you.

    Hi,
    Check the second post at
    http://forum.java.sun.com/thread.jsp?forum=51&thread=229192&start=15&range=15&hilite=false&q=
    -Amol

  • [FR] How to set default member in User POV Preview

    Hi!
    Does anyone know how to set the default member in User POV Preview for first time users?
    Example:
    For dimension Entity, the default member that appear in first login of user is the Top Level member "Dim_Entity", regardless of security. It happens with all first time users.
    We already try to change the User POV in Preferences, but this only limit the choices of user and didn't set the default member.
    We are using version 11.1.1.3.
    Thanks,
    Luís

    Check the following PDF for Manage User POV utility.There is an option to import POV for the users.
    http://docs.oracle.com/cd/E12825_01/epm.111/fr_user.pdf (page 297)
    hope this helps
    Note:Correct forum for FR question is Hyperion Query and Reporting,below is the link.
    Hyperion Query and Reporting
    Thx
    VIVEK
    Edited by: Vivek Chetiaparath on Jan 3, 2013 7:45 AM

  • JDBC / JTA Timeouts : How to set a timeout on the fetching of a query ?

    Hi !
    I'm working on an Application running on Weblogic Server 11g. This app executes a query on an Oracle 11g database ...
    The problem is that this query returns millions of records ... and the app fetches the results during tens of minutes.
    We would like to set a timeout, wich will abandon the transaction, hang the database connection, destroy the socket ... or anything else ...
    This timeout will prevent the thread to become in STUCK state and stucking the weblogic managed server.
    Is this possible ?
    Thank's for your answers.
    Steve.
    Edited by: 966918 on 10 avr. 2013 07:18

    Abandon timeout will not help. That is only used if a database crashes during the second phase of commit. It specifies how long the transaction manager should keep trying to complete the transaction.
    JTA timeout will only work if you are using XA datasources and two-phase commit transactions. When the timeout occurs, it guarantees that the transaction cannot be committed. Eventually, all of the participant resources will be notified and will not allow any more work to take place on the transaction. It does not stop the threads and the application must be written to handle exceptions appropriately.
    Edited by: Steve Felts on Apr 17, 2013 8:32 AM

Maybe you are looking for