Skip to main content
Participant
December 20, 2009
Question

Coldfusion code not working in DW template

  • December 20, 2009
  • 2 replies
  • 481 views

Hi, I have a placed coldfusion code:

<cfif SESSION.Auth.RoleID neq 4>

access denied!!!

<cfabort>

</cfif>

at the very top (outside the html code) of a page created from a dreamweaver template. I did this so that when an unauthorized user clicks on the link to the page that they will not be allowed to view the page but get the message "access denied!!!"

However, the code doesn't seem to be working with the template. When I click the link to the page, the page still displays. It has the words "access denied" at the top of the page but still displays the page which I don't want viewed by the unauthorized user. If I detach the pages from the template, then the code works. Of course, this is not a good solution as I am using a template because of the numerous advantages it delivers when creating a website.

Can anyone tell me why this is happening and what I should do to fix this?

    This topic has been closed for replies.

    2 replies

    Inspiring
    December 26, 2009

    The solution is simple, instead of cfabort use cflocation tag!

    <cfif SESSION.Auth.RoleID neq 4>

    <cflocation url="access denied.cfm" addtoken="no">

    <cfelse>

    </cfif>

    "page content here"

    or try your code like this:

    <cfif SESSION.Auth.RoleID neq 4>

    access denied!!!

    <cfabort>

    <cfelse>

    </cfif>

    "page content here"

    Inspiring
    December 21, 2009

    Hi rianashley,

    Try this and see if things work like you want.

    <cfif SESSION.Auth.RoleID neq 4>

    <!--- Insert access denied!!! here --->

    <cfelse>

    <!--- Insert page content here --->

    </cfif>

    Leonard B