/** * Tests querying session keys from the primary adapter. * The memory adapter returns a UUID. * * @return void */ public function testKey() { $result = Session::key(); $pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}\$/"; $this->assertPattern($pattern, $result); }
<?php use lithium\action\Dispatcher; use lithium\storage\Session; /** * Set the token header in the response. */ Dispatcher::applyFilter('run', function ($self, $params, $chain) { $response = $chain->next($self, $params, $chain); $configs = Session::config(); foreach ($configs as $name => $config) { if ($config['adapter'] == 'Token') { $header = $config['header']; break; } } if (isset($header)) { $response->headers($header, Session::key($name)); } return $response; });