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

Copy link to clipboard

Copied

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

Views

1.2K

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
Community Expert ,
Sep 14, 2014 Sep 14, 2014

Copy link to clipboard

Copied

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.

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