2 Replies Latest reply on Jul 12, 2006 3:34 PM by Newsgroup_User

    CFC redirect

    Level 7
      I am trying to create a login switching CFC based on a database result. It
      basically redirects the user to the right area based on the value in the
      database (memtype).

      It is supposed to direct them one way if it is 'single' another way if it is
      'group' and if nothing, then put them back to the login page (incase someone
      calls up the page in the URL manually).

      It works great if the memtype is either 'single' or 'group', but I cannot
      get the <cfelse> to work if the page is called up manually throught the URL.
      It just shoots them to group directory.

      What am I missing?

      I have:
      <cffunction name="LoginSwitch" access="public" returntype="void">
      <cfquery name="loginswitch" datasource="#Request.MainDSN#">
      SELECT memtype FROM softproofs.members WHERE username =
      <cfif #loginswitch.memtype# EQ 'single'>
      <cflocation url="../dashboard/index.cfm" addtoken="no">
      <cfelseif #loginswitch.memtype# EQ 'group'>
      <cflocation url="../group/index.cfm" addtoken="no">
      <cflocation url="../index.cfm" addtoken="no">

        • 1. Re: CFC redirect
          May want to set a CFParam to ensure the value you are looking for is blank before you try to see if it is Group or Single...

          <CFParam Name="loginswitch.memtype" Default="">
          • 2. Re: CFC redirect
            Level 7
            Thanks. Actually I had to 'IsDefined' the session.username. While trying to
            make sure all 3 worked, I was creating sessions that were causing the login
            page redirect to fail. Since the session is now expired, it works.

            Basically if someone were to login and then try to access that page in the
            URL, it would just send them to their normal logged in dashboard page.
            Trying to access it without logging in first just redirects you back to the
            login page.