Support the ongoing development of Laravel.io →
Requests Input

Hi, I'm starting to learn Laravel framework. I was reading documentation about laravel and also, I was debuging every example on my local server. So my problem is cookies, I have a question "How to create a regular cookie on Laravel framework?"... There is a example of creating cookies using pure/native PHP:

setcookie('name', 'value', time()+3600);

I want to get similar result on Laravel framework...

Notice: I had already tried following code, but it didn't work...

Cookie::make('name', 'value', $minutes)
Last updated 2 years ago.
0

In time field you only have to pass time in minutes so in your case just pass 60

If you look at laravel source In namespace Illuminate\Cookie - CookieJar.php file you can look at this method.

public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true)
	{
		list($path, $domain) = $this->getPathAndDomain($path, $domain);

		$time = ($minutes == 0) ? 0 : time() + ($minutes * 60);

		return new Cookie($name, $value, $time, $path, $domain, $secure, $httpOnly);
	}
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.