Apr 5, 2018
0
Level 17
Generating COOKIE / session from AJAX call
Hello all,
I need to generate cookie in my laravel app from an external AJAX call (from another app). This is my backend Laravel code:
/**
* @param $fingerPrint
* @return \Illuminate\Http\JsonResponse
*/
public function storeFingerPrint($fingerPrint)
{
header('Access-Control-Allow-Origin: *');
if (request()->ajax()) {
session()->put('device_finger_print', $fingerPrint);
$fingerPrintCookie = Cookie::queue('device_finger_print', $fingerPrint, 120);
}
return response()->json(['print' => $fingerPrint]);
}
When i try to access the cookie, I always get null.
Is there any solution to this ?
Please or to participate in this conversation.