Factory.php
TLDR
The Factory
interface in the Illuminate\Contracts\Cookie
namespace provides the contract for creating, expiring, and forgetting cookies.
Methods
make
Create a new cookie instance.
-
Parameters:
-
$name
(string): The name of the cookie. -
$value
(string): The value of the cookie. -
$minutes
(int, optional): The number of minutes until the cookie expires. Defaults to0
. -
$path
(string|null, optional): The path for the cookie. Defaults tonull
. -
$domain
(string|null, optional): The domain for the cookie. Defaults tonull
. -
$secure
(bool|null, optional): Indicates if the cookie should only be sent over HTTPS. Defaults tonull
. -
$httpOnly
(bool, optional): Indicates if the cookie should only be accessible through the HTTP protocol. Defaults totrue
. -
$raw
(bool, optional): Indicates if the cookie value should be sent without URL encoding. Defaults tofalse
. -
$sameSite
(string|null, optional): The SameSite attribute of the cookie. Defaults tonull
.
-
-
Returns:
\Symfony\Component\HttpFoundation\Cookie
forever
Create a cookie that lasts "forever" (five years).
-
Parameters:
-
$name
(string): The name of the cookie. -
$value
(string): The value of the cookie. -
$path
(string|null, optional): The path for the cookie. Defaults tonull
. -
$domain
(string|null, optional): The domain for the cookie. Defaults tonull
. -
$secure
(bool|null, optional): Indicates if the cookie should only be sent over HTTPS. Defaults tonull
. -
$httpOnly
(bool, optional): Indicates if the cookie should only be accessible through the HTTP protocol. Defaults totrue
. -
$raw
(bool, optional): Indicates if the cookie value should be sent without URL encoding. Defaults tofalse
. -
$sameSite
(string|null, optional): The SameSite attribute of the cookie. Defaults tonull
.
-
-
Returns:
\Symfony\Component\HttpFoundation\Cookie
forget
Expire the given cookie.
-
Parameters:
-
$name
(string): The name of the cookie. -
$path
(string|null, optional): The path for the cookie. Defaults tonull
. -
$domain
(string|null, optional): The domain for the cookie. Defaults tonull
.
-
-
Returns:
\Symfony\Component\HttpFoundation\Cookie
<?php
namespace Illuminate\Contracts\Cookie;
interface Factory
{
/**
* Create a new cookie instance.
*
* @param string $name
* @param string $value
* @param int $minutes
* @param string|null $path
* @param string|null $domain
* @param bool|null $secure
* @param bool $httpOnly
* @param bool $raw
* @param string|null $sameSite
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function make($name, $value, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null);
/**
* Create a cookie that lasts "forever" (five years).
*
* @param string $name
* @param string $value
* @param string|null $path
* @param string|null $domain
* @param bool|null $secure
* @param bool $httpOnly
* @param bool $raw
* @param string|null $sameSite
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forever($name, $value, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null);
/**
* Expire the given cookie.
*
* @param string $name
* @param string|null $path
* @param string|null $domain
* @return \Symfony\Component\HttpFoundation\Cookie
*/
public function forget($name, $path = null, $domain = null);
}