From one function I am setting a session and from another function, I would like to get the value of that session.
// Set the session
public function setSession($data) {
$this->get('session')->set('id', $this->loginDao->getId($data['email']));
return true;
}
// Get the session
public function getSession() {
return new Response(json_encode($this->get('session')->get('id')));
}
My problem is that getSession
returns null
.
I have tested it with Postman and that works! What I have realized is that Postman has PHPSESSID=1a2714euatml19jj4p1rq9sbsa
as Cookie in header but in Chrome it's missing.
This is how the header looks like in Chrome:
Correct me if I am wrong, but I guess Set-Cookie
is missing here.
However, what is the reason that it works in Postman but not in the browser? And how can I fix this?