• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CFC redirect

LEGEND ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

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:
<cfcomponent>
<cffunction name="LoginSwitch" access="public" returntype="void">
<cfquery name="loginswitch" datasource="#Request.MainDSN#">
SELECT memtype FROM softproofs.members WHERE username =
'#SESSION.MM_username#'
</cfquery>
<cfif #loginswitch.memtype# EQ 'single'>
<cflocation url="../dashboard/index.cfm" addtoken="no">
<cfelseif #loginswitch.memtype# EQ 'group'>
<cflocation url="../group/index.cfm" addtoken="no">
<cfelse>
<cflocation url="../index.cfm" addtoken="no">
</cfif>
</cffunction>
</cfcomponent>


TOPICS
Advanced techniques

Views

353

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

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="">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2006 Jul 12, 2006

Copy link to clipboard

Copied

LATEST
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.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation