Hello,
I'm trying to build a session driver with cookie. It seems that "write" method works ok and creates cookie with value provided. But "read" method cannot retrieved the cookie value.
Can someone help me?
Regards, Velizar
<?php
class Cookie extends Adapter implements AdapterInterface
{
protected $isDestroyed = false;
public function __construct($options = null)
{
parent::__construct($options);
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
}
public function open()
{
return true;
}
public function close()
{
return false;
}
public function read($sessionId)
{
return $_COOKIE[$sessionId]; // everytime this line returns an error undefined index
}
public function write($sessionId, $data)
{
secookie($sessionId, $data, .....);
}
public function destroy($session_id = null)
{
}
public function gc($maxlifetime)
{
}
}