user10975763
user10975763

Reputation:

Laravel Cookie get value

I'm trying to get cookies data but i'm getting as output the follow array:

"s:7:"MaSP5Jd";"

Code for get the Cookie value:

$referred_by = Cookie::get('referral');

The output must be only: MaSP5Jd Can someone help me to get this output good out?

For set the Cookie i have created middleware:

    public function handle($request, Closure $next)
{
    $response = $next($request);

    if (! $request->hasCookie('referral') && $request->query('ref') ) {
      $response->cookie('referral', encrypt( $request->query('ref') ), 525600 );
    }

    return $response;
}

Upvotes: 0

Views: 264

Answers (1)

STA
STA

Reputation: 34688

You can set on Session like this :

Session::put('referral', "MaSP5Jd");

Code for get the Session value :

Session::get('referral'); // output "MaSP5Jd"

Upvotes: 1

Related Questions