master

laravel/framework

Last updated at: 29/12/2023 09:24

Session.php

TLDR

This file contains the Session class, which is a facade for accessing and manipulating session data in Laravel applications.

Methods

shouldBlock()

Returns whether the session should be blocked.

blockDriver()

Returns the block driver being used for the session or null if no block driver is specified.

defaultRouteBlockLockSeconds()

Returns the default number of seconds that the session should be locked.

defaultRouteBlockWaitSeconds()

Returns the default number of seconds to wait for the session to be unlocked.

getSessionConfig()

Returns the session configuration.

getDefaultDriver()

Returns the name of the default session driver.

setDefaultDriver(string $name)

Sets the default session driver.

driver(string|null $driver = null)

Gets an instance of the session driver or sets the driver to be used.

extend(string $driver, \Closure $callback)

Extend the session driver with a custom driver.

getDrivers()

Returns an array of all registered session drivers.

getContainer()

Returns the container instance.

setContainer(\Illuminate\Contracts\Container\Container $container)

Sets the container instance.

forgetDrivers()

Forgets all of the driver instances.

start()

Starts the session.

save()

Saves the session data.

ageFlashData()

Ages the flash data for the session.

all()

Returns all session data.

only(array $keys)

Returns only the specified session data.

exists(string|array $key)

Checks if the session data exists.

missing(string|array $key)

Checks if the session data is missing.

has(string|array $key)

Checks if the session data has the specified key(s).

get(string $key, mixed $default = null)

Gets the value of the session data with the specified key.

pull(string $key, mixed $default = null)

Gets and removes the value of the session data with the specified key.

hasOldInput(string|null $key = null)

Checks if there is old input for the session.

getOldInput(string|null $key = null, mixed $default = null)

Gets the old input value for the session.

replace(array $attributes)

Replaces all session attributes with the specified attributes.

put(string|array $key, mixed $value = null)

Puts the specified key-value pair(s) into the session.

remember(string $key, \Closure $callback)

Gets the value of the session data with the specified key, or sets it using the callback if it doesn't exist.

push(string $key, mixed $value)

Pushes a value onto a session array.

increment(string $key, int $amount = 1)

Increments the value of a session data item.

decrement(string $key, int $amount = 1)

Decrements the value of a session data item.

flash(string $key, mixed $value = true)

Flash a key-value pair to the session.

now(string $key, mixed $value)

Puts the specified key-value pair into the session only for the current request.

reflash()

Keeps all of the current flash data for another request.

keep(array|mixed $keys = null)

Keeps the specified session keys.

flashInput(array $value)

Flash the input for the current request.

remove(string $key)

Removes the value of the specified session key.

forget(string|array $keys)

Forgets the specified session key(s).

flush()

Removes all of the session data.

invalidate()

Invalidates the session data.

regenerate(bool $destroy = false)

Regenerates the session ID.

migrate(bool $destroy = false)

Migrates the session to a new ID.

isStarted()

Checks if the session has been started.

getName()

Gets the session name.

setName(string $name)

Sets the session name.

getId()

Gets the session ID.

setId(string|null $id)

Sets the session ID.

isValidId(string|null $id)

Checks if the session ID is valid.

setExists(bool $value)

Sets whether the session exists.

token()

Gets the CSRF token for the session.

regenerateToken()

Regenerates the CSRF token for the session.

previousUrl()

Gets the previous URL for the session.

setPreviousUrl(string $url)

Sets the previous URL for the session.

passwordConfirmed()

Marks the password as confirmed for the session.

getHandler()

Gets the session handler.

setHandler(\SessionHandlerInterface $handler)

Sets the session handler.

handlerNeedsRequest()

Checks if the session handler needs a request.

setRequestOnHandler(\Illuminate\Http\Request $request)

Sets the request on the session handler.

macro(string $name, object|callable $macro)

Defines a new macro.

mixin(object $mixin, bool $replace = true)

Mixin another object into the session.

hasMacro(string $name)

Checks if a macro is defined.

flushMacros()

Flushes all of the macros.

Classes

No classes found.

<?php

namespace Illuminate\Support\Facades;

/**
 * @method static bool shouldBlock()
 * @method static string|null blockDriver()
 * @method static int defaultRouteBlockLockSeconds()
 * @method static int defaultRouteBlockWaitSeconds()
 * @method static array getSessionConfig()
 * @method static string getDefaultDriver()
 * @method static void setDefaultDriver(string $name)
 * @method static mixed driver(string|null $driver = null)
 * @method static \Illuminate\Session\SessionManager extend(string $driver, \Closure $callback)
 * @method static array getDrivers()
 * @method static \Illuminate\Contracts\Container\Container getContainer()
 * @method static \Illuminate\Session\SessionManager setContainer(\Illuminate\Contracts\Container\Container $container)
 * @method static \Illuminate\Session\SessionManager forgetDrivers()
 * @method static bool start()
 * @method static void save()
 * @method static void ageFlashData()
 * @method static array all()
 * @method static array only(array $keys)
 * @method static bool exists(string|array $key)
 * @method static bool missing(string|array $key)
 * @method static bool has(string|array $key)
 * @method static mixed get(string $key, mixed $default = null)
 * @method static mixed pull(string $key, mixed $default = null)
 * @method static bool hasOldInput(string|null $key = null)
 * @method static mixed getOldInput(string|null $key = null, mixed $default = null)
 * @method static void replace(array $attributes)
 * @method static void put(string|array $key, mixed $value = null)
 * @method static mixed remember(string $key, \Closure $callback)
 * @method static void push(string $key, mixed $value)
 * @method static mixed increment(string $key, int $amount = 1)
 * @method static int decrement(string $key, int $amount = 1)
 * @method static void flash(string $key, mixed $value = true)
 * @method static void now(string $key, mixed $value)
 * @method static void reflash()
 * @method static void keep(array|mixed $keys = null)
 * @method static void flashInput(array $value)
 * @method static mixed remove(string $key)
 * @method static void forget(string|array $keys)
 * @method static void flush()
 * @method static bool invalidate()
 * @method static bool regenerate(bool $destroy = false)
 * @method static bool migrate(bool $destroy = false)
 * @method static bool isStarted()
 * @method static string getName()
 * @method static void setName(string $name)
 * @method static string getId()
 * @method static void setId(string|null $id)
 * @method static bool isValidId(string|null $id)
 * @method static void setExists(bool $value)
 * @method static string token()
 * @method static void regenerateToken()
 * @method static string|null previousUrl()
 * @method static void setPreviousUrl(string $url)
 * @method static void passwordConfirmed()
 * @method static \SessionHandlerInterface getHandler()
 * @method static \SessionHandlerInterface setHandler(\SessionHandlerInterface $handler)
 * @method static bool handlerNeedsRequest()
 * @method static void setRequestOnHandler(\Illuminate\Http\Request $request)
 * @method static void macro(string $name, object|callable $macro)
 * @method static void mixin(object $mixin, bool $replace = true)
 * @method static bool hasMacro(string $name)
 * @method static void flushMacros()
 *
 * @see \Illuminate\Session\SessionManager
 */
class Session extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'session';
    }
}