Azer Qurbanov
Azer Qurbanov

Reputation: 61

Laravel check if cookie exits

I am newer in Laravel. I'd like to make web page gets redirected to another domain if cookie does't exists. for ex: when i enter to www.somesite.com, let it checks first cookie ($_COOKIE['SSO-Token']). if there is not one it redirects to another domain for logging. I need to make it only in Laravel. Any helps greatly appreciated. Thanks in advance to anyone who will help me.

Upvotes: 0

Views: 1958

Answers (1)

Sanzeeb Aryal
Sanzeeb Aryal

Reputation: 3266

If the cookie has been set, you can show with:

public function showCookie(Request $request) {
        return $request->cookie('name');
    }

To check for specific cookie:

$value = $request->cookie('name');
if($value)
{
   //cookie exists
}

See documentation

Upvotes: 1

Related Questions