I have some data I want to store in session:
$data = array
(
'id' => '23539471'
'token' => 'cf310b81-9431-4303-804d-c1635ae29278'
);
In my plugin I am doing this:
new HttpCookie('myCookieName', $data, [ 'expire' => time() + 3600 ]);
When I dd() that I can see the cookie as expected:
Craft\HttpCookie#1
(
[name] => 'myCookieName'
[value] => array
(
'id' => '23539471'
'token' => 'cf310b81-9431-4303-804d-c1635ae29278'
)
[domain] => ''
[expire] => 1427328767
[path] => '/'
[secure] => true
[httpOnly] => true
[CComponent:_e] => null
[CComponent:_m] => null
)
However on the next page load the cookie is null:
$cookie = craft()->request->getCookie('myCookieName');
What am I doing wrong here?
::::EDIT::::
I have also tried this which seems to make the cookie available in the current request, but it's null on the next request:
$cookie = new HttpCookie('myCookieName', $data);
$cookie->expire = time() + 3600;
craft()->request->cookies->add('myCookieName', $cookie);