2 Replies Latest reply on Aug 15, 2006 2:32 PM by <newbie />

    CFTry / CFCatch

    Level 7
      In a couple of my cfcs I reference the session_mmusername.
      What cftry/cfcatch can I use in the cfc around the query to redirect the
      user to a login page if the session expires?

      Wally Kolcz
      Developer / Support

        • 1. Re: CFTry / CFCatch
          Level 7
          Figured it out. 'any' works fine.

          • 2. Re: CFTry / CFCatch
            <newbie /> Level 1
            I'm glad you got it working.

            However, you may want to consider checking if the variable exists instead of using try/catch.

            Also, you may not want to reference the session scope in your queries.

            For example...

            <cfset var userId = 0 />

            <cfif NOT IsDefined("session.mmusername")>
            <cflocation url="..." />
            <cfset userId = session.mmusername />
            <cfquery name="myQuery" datasource="myDsn">
            SELECT * FROM myTable
            WHERE username = <cfqueryparam value="#userId#" />