Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#18980 closed defect (bug) (invalid)

Firefox + setcookie() + WordPress = wrong cookie data

Reported by: obscurecloud's profile obscurecloud Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:

Description (last modified by SergeyBiryukov)

Just pointing out an interesting issue I ran into with WordPress.

While this is not normal usage, I have a template that includes the PHP function setcookie().

Firefox parses the adjacent post link in the head of the document.

In this situation, it caused the cookie data to be incorrect. It was set to the next page's data and not the page currently being viewed.

Change History (2)

#1 @SergeyBiryukov
12 years ago

  • Description modified (diff)
  • Summary changed from Firefox + setcookie() + Wordpress = wrong cookie data to Firefox + setcookie() + WordPress = wrong cookie data

#2 @dd32
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Your problem is that Firefox is anticipating the users movements, and automatically loading the adjacent post into memory/cache, in doing so, it'll set any cookies which that page returns.

Ideally, any cookies with per-page information should be prefixed with the post ID, and/or better suited to be printed as inline javascript in the footer/headers.. doing it that way will not cause you problems.

However, this is not a WordPress bug, it's just the way your PHP interacts with a browser, it's not something that WordPress can 'fix', nor affect.. (Other than not including the adjacent posts links), It'll happen with *any* php/application which firefox interacts with which doesn't use unique cookie names.

Closing as invalid due to that..

Note: See TracTickets for help on using tickets.