I am creating referral system . Every thing is ok, but I am unable to retrieve serialize value from database. Here is my middle-ware code.
public function handle($request, Closure $next)
{
$response = $next($request);
// Check that there is not already a cookie set and that we have 'ref' in the url
if (! $request->hasCookie('referral') && $request->query('ref') ) {
// Add a cookie to the response that lasts 5 years (in minutes)
$response->cookie( 'referral', encrypt( $request->query('ref') ), 525600 );
}
else {
if( $request->query('ref') ) {
return redirect($request->fullUrl())->withCookie(cookie()->forever('referral', $request->query('ref')));
}
}
return $response;
}
}
Here Is my register Code . $referred_by = Cookie::get('referral'); line is returning like s:1:"1"; And these value saved in databases.
protected function create(array $data)
{
$referred_by = Cookie::get('referral');
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
'referred_by' => $referred_by,
]);
}
Now I am trying to retrieve this for view .but Unable to decode this value. s:1:"1";
Any help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire