Hello everyone.

I'm working on website with a desktop and mobile versions.

I'm using ThemeKey to switch between desktop and mobile theme.

I'm using the system:session property, and i find something strange.

I have two sessions
array(2) {
["viewactu"]=>
bool(true)
["toDesc"]=>
bool(true)
}

But the value calculatde by ThemeKey of system:session was only
["system:session"]=>
array(1) {
[0]=>
string(1) "1"
}

After searching in the code, I find in themekey.system.inc

function themekey_dummy2session($dummy) {
  $filtered_params = array();
  if (!empty($_SESSION)) {
    foreach ($_SESSION as $key => $value) {
      if (is_bool($value)) {
        $filtered_params[] = $key . '=' . ($value) ? '1' : '0';
      }
      elseif (!empty($value) && (is_numeric($value) || is_string($value))) {
        $filtered_params[] = $key . '=' . $value;
      }
      else {
        $filtered_params[] = $key;
      }
    }
  }
  return count($filtered_params) ? array_unique($filtered_params) : NULL;
}

The problem come with $filtered_params[] = $key . '=' . ($value) ? '1' : '0';

Replacing it by $filtered_params[] = $key . '=' . ( ($value) ? '1' : '0');

And we have as value :

["system:session"]=>
array(2) {
[0]=>
string(10) "viewactu=1"
[1]=>
string(8) "toDesc=1"
}

it work better now.

For people who are in trouble with system:session it can help you !

Comments

mkalkbrenner’s picture

Title: system:session » wrong boolean values in system:session
Version: 7.x-2.3 » 6.x-4.x-dev
Assigned: Unassigned » mkalkbrenner
Category: support » bug
Status: Needs review » Patch (to be ported)

you're right. Patch committed to 7.x-2.x and 7.x-3.x.

mkalkbrenner’s picture

Assigned: mkalkbrenner » Unassigned
Issue tags: -session +Needs backport to D6, +Novice
mkalkbrenner’s picture

Project: ThemeKey » ThemeKey Properties
Component: Code / API » Code
Issue summary: View changes
mkalkbrenner’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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