I recently saw that when I open of my sites as a anonymous user, a session cookie is set. I checked the database sessions table, and there is a line for uid 0 as well. How can I prevent drupal from setting this cookie?

Greetings SG

This is what the cookie looks like in the session table:

enter image description here

Sry that the image is so tiny ...

  • And why would you want that, exactly? – Mołot Aug 29 '14 at 14:29
  • I want to work with Nginx and this is checking if a session cookie is set or not. – Sebastian Aug 29 '14 at 14:29
  • Drupal 7 already only sets session cookie for anonymous if there is something session-dependent, like form, or module that needs sessions. "Simply" remove everything that requires sessions for anonymous and you are set. For Drupal 6, see drupal.org/project/no_anon – Mołot Aug 29 '14 at 14:31

Drupal7 unlike drupal6 does not use sessions for anon users. This is an improvement for performance reasons. If you see that there are sessions created it means that there is a contrib module that creates them, so it may be a bad idea disabling them. You can inspect the contents of the session to get an idea which module is using it.

If this is d6 site, you may check the pressflow distribution.

  • Thx for your respons. I first thought the cookie gots added by my search form, but i was wrong with it ... For now it looks like it sometimes appears, and sometimes it disappears :/ I updated my post with my session table. – Sebastian Sep 1 '14 at 7:21
  • It seems that you are using the pagestyle module ? – Mike Sep 1 '14 at 7:52
  • I saw it myself in the moment I did the screenshot ... :O After updating the module to the latest dev, the cookie is gone, I'll create a answer for this question. – Sebastian Sep 1 '14 at 8:01

As mentioned in my comments above, the problem where provided by the "Pagestyle" module. The 7.x-1.0 is pretty old for now and its creating this cookie for any anonymous user.

You can fix the problem by updating the module to the newest dev release. After this you've to configure the module here: admin/config/user-interface/pagestyle

And set "Scripting languages" to "PHP + JavaScript + Optimized for performance"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.