Skip to main content
Participant
August 14, 2008
Question

Coldfusion and Cookies

  • August 14, 2008
  • 3 replies
  • 436 views
I am trying to work on something where whenever a user is logged in my site, it shows a logout image link for them in the header top area section. Whenever they are not logged in, the image of login comes in with a link instead. Any help would be appreciated.
This topic has been closed for replies.

3 replies

Inspiring
August 14, 2008
Are you using the CF login framework?

<cflogin...
login code here.
</cflogin>

If yes, you could just use:
<cfif isUserLoggedIn()>
show logo
<cfelse>
show link
</cfif>
Inspiring
August 14, 2008
Slight problem with the cookie approach. It might still be there the next time the user comes to the site and doesn't log on.

Session variables would be better.
Inspiring
August 14, 2008
To control this with cookies:

<cfif Not IsDefined('cookie.yoursite')>
Show login image
<cfelseif IsDefined('cookie.yoursite')>
Show LogOut image
</cfif>

Once user has logged in using your login form, set the cookie:
<cfcookie name="yoursite" value=#id#>

et voila?! (if storing the user's ID in a cookie I would recommend encypting first, using #Encrypt())