CMS Drupal Mastering Development

Session variable and cache drupal

I’ve created a small helper where I can set and access my session variable (thanks to the drupal 8 session).

Can’t figure out why, my session is working well with my dev (no cache) but on my prod my session is not persisted, need to refresh drupal cache to see my session variable…

  public static function getSessionIRA()
    return self::getModuleStore()->get('session_ira');

  public static function setSessionIRA($session_ira)
    return self::getModuleStore()->set('session_ira', $session_ira);

   * @return mixed
  private static function getModuleStore()
    return \Drupal::request()->getSession();

    return self::$module_store = \Drupal::service('user.private_tempstore')->get('mymodule_services');

Leave a Reply

Your email address will not be published. Required fields are marked *