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

Coldfusion and Cookies

New Here ,
Aug 14, 2008 Aug 14, 2008
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.
TOPICS
Getting started
396
Translate
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
Participant ,
Aug 14, 2008 Aug 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())
Translate
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 ,
Aug 14, 2008 Aug 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.
Translate
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
Participant ,
Aug 14, 2008 Aug 14, 2008
LATEST
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>
Translate
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