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

How can you determine from within CF if cookies are enabled in the browser you are using?

Participant ,
Sep 13, 2014 Sep 13, 2014

I need to know if the user has cookies enabled when he logs into my website so I can tell him/her to enable them.  If they are not enabled, the SessionID will be lost and session vars will not work.

TOPICS
Advanced techniques
1.3K
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
Community Expert ,
Sep 14, 2014 Sep 14, 2014
LATEST

Enable session management in your Application file, with setClientCookies set to true. Then you can tell whether the client has cookies enabled by looking at the values in the cookie scope, by doing something like

<cfif isDefined("cookie.cfid") and isDefined("cookie.cftoken")>

<!--- cookies enabled --->

<cfelse>

<!--- we may assume cookies not enabled --->

</cfif>

If you are on ColdFusion 10 or 11 you should read up on the related subject of session fixation.

You might wish to avoid re-inventing the wheel. If so, you could just emulate or copy Ben Nadel's cookie test.

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