Cookie::get PHP Method

get() public method

Accessor function for properties in the $_SESSION array
public get ( string $name = null ) : string | null
$name string The name of the property to retrieve (optional)
return string | null The value of the property, or null if it does not exist. If no `$name` is provided, return the entire Cookie.
    public function get($name = null)
    {
        if (is_null($name) && isset($_SESSION[$this->_index])) {
            return $_SESSION[$this->_index];
        }
        if (isset($_SESSION[$this->_index]) && is_array($_SESSION[$this->_index]) && array_key_exists($name, $_SESSION[$this->_index])) {
            return $_SESSION[$this->_index][$name];
        }
        return null;
    }

Usage Example

Ejemplo n.º 1
1
function Check_User_Cart()
{
    $Identifier = '';
    if (!Sentry::check()) {
        return false;
    } else {
        $Identifier = Sentry::user()->id;
        if (Cookie::has('Anon_Cart_Extension')) {
            $AnonIdentifier = Cookie::get('Anon_Cart_Extension');
            $dataAnon = Cache::get('user_cart.' . $AnonIdentifier);
            if (Cache::has('user_cart.' . $Identifier)) {
                $dataUser = Cache::get('user_cart.' . $Identifier);
                if ($dataAnon != null && $dataUser != null) {
                    foreach ($dataAnon as $key => $value) {
                        if (!isset($dataUser[$key])) {
                            $dataUser[$key] = $value;
                        }
                    }
                    Cache::forever('user_cart.' . $Identifier, $dataUser);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            } else {
                if ($dataAnon != null) {
                    Cache::forever('user_cart.' . $Identifier, $dataAnon);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            }
        }
    }
}
All Usage Examples Of Cookie::get