I've developed an anonymous flagging feature on my local server which is working great.

I've pushed the site to Pantheon and the anonymous flagging is no longer working, I've disabled all caching & aggregation. Session API is definitely enabled.

The flag javascript toggle displays a throbber, changes to 'unflag link' and appears to have flagged the entity, but on page refresh, the flag is reset.

This is only happening for anonymous users, the flags work fine when logged in.

Any advice you could provide would be much appreciated!

Comments

dsquaredb’s picture

Adding this comment since the issues may be related.

Seems to be some issues with anonymous user flags and some Pantheon configuration. My local dev site works fine, also, but have problems on Pantheon. On my site on Pantheon, anonymous users can flag and unflag content, but they get the No Results message on the views of the flagged content. By accident I discovered that if an anonymous user flags content, then attempts to log in to the site unsuccessfully, then the page will refresh and the flagged content will appear in the views.

PI_Ron’s picture

Status: Active » Closed (fixed)

Hi DSquaredB,

Apologies for not following this up earlier, I was meaning to post the solution I found. The cause for anonymous flagging issues is a cookie name used by the Session API module. Please see comment on below issue for renaming info:

https://drupal.org/comment/8284387#comment-8284387

I don't know about cookie stripping on *responses*, but many configurations will strip "useless" cookies from the request too. Typically this is a good thing (Google Analytics, other sites on the domain/s, etc.) but causes problems when it removes a cookie you need.

In Pantheon's case, Drupal will *only* see cookies that match the pattern /SESS.*/ because Varnish will strip all other cookies from the request before forwarding it to the upstream server. Renaming the Session API cookie to SESSsessionapi gets around this stripping and Flag and my custom code using Session API all work fine on Pantheon now.

Cheers.