在Laravel中设置cookie后,我尝试使用此代码检索它的内容。它返回所有时间null,但cookie已设置:
public function postRegister(Request $request)
{
$validator = $this->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException(
$request, $validator
);
}
$value = \Request::cookie('affiliate_id');
dd( $value );
$user = $this->create($request->all());
return redirect()->back()->with('status', trans('account.verify'));
}
正如您所看到的,cookie" affiliate_id"的价值不是空的。