Compare commits
4
Commits
f2ad49d8ab
..
v1.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17a83db6c2 | ||
|
|
d688a4c49d | ||
|
|
1694a0f284 | ||
|
|
302b1cc8f6 |
No files matched your search
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Dave Mc Nicoll",
|
"name": "Dave Mc Nicoll",
|
||||||
"email": "dave.mcnicoll@cslsj.qc.ca"
|
"email": "info@mcnd.ca"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
|||||||
+8
-4
@@ -32,7 +32,7 @@ class Cookie {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function set(
|
public function set(
|
||||||
?string $name,
|
?string $key,
|
||||||
?string $value = null,
|
?string $value = null,
|
||||||
?int $expires = null,
|
?int $expires = null,
|
||||||
?string $path = null,
|
?string $path = null,
|
||||||
@@ -47,9 +47,11 @@ class Cookie {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$key = $this->normalizeKey($key);
|
||||||
|
|
||||||
$expires = ! $expires ? 0 : time() + (int) $expires;
|
$expires = ! $expires ? 0 : time() + (int) $expires;
|
||||||
|
|
||||||
$_COOKIE[$name] = $value;
|
$_COOKIE[$key] = $value;
|
||||||
|
|
||||||
$options = [
|
$options = [
|
||||||
'expires' => $this->options['expires'] ?? ( $expires ?: 0 ),
|
'expires' => $this->options['expires'] ?? ( $expires ?: 0 ),
|
||||||
@@ -64,7 +66,7 @@ class Cookie {
|
|||||||
$value = sha1($this->secureHash . $value . $this->secureHash) . "|$value";
|
$value = sha1($this->secureHash . $value . $this->secureHash) . "|$value";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $raw ? setrawcookie($name, $value ?: "", $options) : setcookie($name, $value ?: "", $options);
|
return $raw ? setrawcookie($key, $value ?: "", $options) : setcookie($key, $value ?: "", $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,6 +91,8 @@ class Cookie {
|
|||||||
list($hash, $value) = explode('|', $_COOKIE[$key], 2);
|
list($hash, $value) = explode('|', $_COOKIE[$key], 2);
|
||||||
|
|
||||||
if (! $this->isSecure($hash, $value)) {
|
if (! $this->isSecure($hash, $value)) {
|
||||||
|
$this->delete($key);
|
||||||
|
|
||||||
throw new Exception\CookieInvalidSecureHashException("Invalid cookie hash value given.");
|
throw new Exception\CookieInvalidSecureHashException("Invalid cookie hash value given.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,6 +163,6 @@ class Cookie {
|
|||||||
|
|
||||||
protected function normalizeKey(string $key) : string
|
protected function normalizeKey(string $key) : string
|
||||||
{
|
{
|
||||||
return str_replace(['.', ' ',], '_', $key);
|
return str_replace([',', ';', ' ', '='], '_', $key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user