Anonymous flags use session_api AND a cookie

Created on 7 June 2017, over 8 years ago
Updated 19 August 2025, 2 months ago

Flag allows anonymous flags using session_api. Very very good. This should mean session_api is fully and only responsible for storage. However, flag_flag::uses_anonymous_cookies() uses a different approach to see whether to use FlagCookieStorage (which sets a flags cookie).

Before:

  /**
   * Returns TRUE if this flag requires anonymous user cookies.
   */
  function uses_anonymous_cookies() {
    global $user;
    return $user->uid == 0 && variable_get('cache', 0);
  }

Fixed:

  /**
   * Returns TRUE if this flag requires anonymous user cookies.
   */
  function uses_anonymous_cookies() {
    global $user;
    return $user->uid == 0 && variable_get('cache', 0) && !module_exists('session_api');
  }

If session_api is enabled, don't use a cookie.

🐛 Bug report
Status

Closed: outdated

Version

3.9

Component

Flag core

Created by

🇳🇱Netherlands rudiedirkx

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024