Problem/Motivation

jQuery.cookie behaves differently between versions.

The Drupal7-bundled jquery.cookie.js (is very old) does not encode cookie names, while jquery_update module and Drupal8 provide newer versions of jQuery.cookie plug-in, which unconditionally encode cookie name and optionally encode cookie value.

P.S.: This behavior was not obvious, thatswhy issue #2597171: Do not encode cookie name was created.
P.P.S: Style Switcher 6.x-2.0 uses its own version of jQuery.cookie which is consistent with PHP behavior. (Drupal6 does not bundled with jQuery.cookie.)

Proposed resolution

Write a workaround. An obvious solution is to follow 6.x-2.0 style and use own code instead of jQuery plug-in.

P.S.: PHP always encodes cookie value but not the name (Tested with PHPs: 5.3.29, 5.4.45, 5.5.30, 5.6.14, 7.0.0RC3). This consistency should be preserved.

Comments

pingwin4eg created an issue. See original summary.

pingwin4eg’s picture

Issue summary: View changes
pingwin4eg’s picture

Issue summary: View changes
pingwin4eg’s picture

Title: Optional url-encoding by jQuery.cookie » Workaround jQuery.cookie() inconsistency
Issue summary: View changes
Status: Active » Needs review
StatusFileSize
new3.3 KB
pingwin4eg’s picture

For similarity of code between branches here's a reformatted Drupal.styleSwitcher.cookie() for 6.x. This patch does not fix anything.

pingwin4eg’s picture

pingwin4eg’s picture

Tested patches on:

  1. clean D7
  2. D7 w/ jquery_update
  3. D6
  4. D8

So because this is a critical issue I'm going to commit this as soon as I can.

  • pingwin4eg committed 9f85b85 on 7.x-2.x
    Issue #2623122 by pingwin4eg: Workaround jQuery.cookie() inconsistency
    

  • pingwin4eg committed 8241bbd on 6.x-2.x
    Issue #2623122 by pingwin4eg: Workaround jQuery.cookie() inconsistency
    
pingwin4eg’s picture

Status: Needs review » Fixed

  • pingwin4eg committed 9f85b85 on 8.x-2.x
    Issue #2623122 by pingwin4eg: Workaround jQuery.cookie() inconsistency
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.