I have a larval project i am trying to store some user data in a cookie, However when i try to read it from the other controller i am getting NULL value, i am unable to read the cookie Please help me with any suggestion to fix
Code to create cookie:
` $cookieData = [
'user_id' => $user->id,
'email' => $user->email,
'login_status' => true,
];
// Create a cookie with a one-day validity
$cookie = cookie('user_info', json_encode($cookieData), 1440);
return response()->json(['message' => 'Authentication successful'])->withCookie($cookie);
`
Code used to read the cookie:
`$abc=$request->cookie('user_info');
$value = Cookie::get('user_info');
if (Cookie::has('user_info'))
{} `
click to view Debugger output
exempted the cookie from encryption from middle ware, route is also set on web, still the code is unable to read the cookie
user25439100 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.