Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
c9bb800e
Commit
c9bb800e
authored
Feb 24, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaning up the cookie class.
parent
9019c6e2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
cookie.php
laravel/cookie.php
+14
-12
No files found.
laravel/cookie.php
View file @
c9bb800e
...
@@ -31,9 +31,9 @@ class Cookie {
...
@@ -31,9 +31,9 @@ class Cookie {
{
{
if
(
headers_sent
())
return
false
;
if
(
headers_sent
())
return
false
;
// All cookies are stored in the "jar" when set and not sent directly to
the
// All cookies are stored in the "jar" when set and not sent directly to
//
browser. This simply makes testing all of the cookie stuff very eas
y
//
the browser. This simply makes testing all of the cookie stuff ver
y
//
since the jar can be inspected by the application's
tests.
//
easy since the jar can be inspected by
tests.
foreach
(
static
::
$jar
as
$cookie
)
foreach
(
static
::
$jar
as
$cookie
)
{
{
static
::
set
(
$cookie
);
static
::
set
(
$cookie
);
...
@@ -52,18 +52,21 @@ class Cookie {
...
@@ -52,18 +52,21 @@ class Cookie {
$time
=
(
$minutes
!==
0
)
?
time
()
+
(
$minutes
*
60
)
:
0
;
$time
=
(
$minutes
!==
0
)
?
time
()
+
(
$minutes
*
60
)
:
0
;
// A cookie payload can't exceed 4096 bytes, so if the payload is greater
// than that, we'll raise an error to warn the developer since it could
// cause serious cookie-based session problems.
$value
=
static
::
sign
(
$name
,
$value
);
$value
=
static
::
sign
(
$name
,
$value
);
// A cookie payload can't exceed 4096 bytes, so if the cookie payload
// is greater than that, we'll raise an error to warn the developer
// since it could cause cookie session problems.
if
(
strlen
(
$value
)
>
4000
)
if
(
strlen
(
$value
)
>
4000
)
{
{
throw
new
\Exception
(
"Payload too large for cookie."
);
throw
new
\Exception
(
"Payload too large for cookie."
);
}
}
else
{
setcookie
(
$name
,
$value
,
$time
,
$path
,
$domain
,
$secure
);
setcookie
(
$name
,
$value
,
$time
,
$path
,
$domain
,
$secure
);
}
}
}
/**
/**
* Get the value of a cookie.
* Get the value of a cookie.
...
@@ -91,12 +94,11 @@ class Cookie {
...
@@ -91,12 +94,11 @@ class Cookie {
// The hash signature and the cookie value are separated by a tilde
// The hash signature and the cookie value are separated by a tilde
// character for convenience. To separate the hash and the contents
// character for convenience. To separate the hash and the contents
// we can simply expode on that character.
// we can simply expode on that character.
//
// By re-feeding the cookie value into the "sign" method we should
// be able to generate a hash that matches the one taken from the
// cookie. If they don't, the cookie value has been changed.
list
(
$hash
,
$value
)
=
explode
(
'~'
,
$value
,
2
);
list
(
$hash
,
$value
)
=
explode
(
'~'
,
$value
,
2
);
// By re-feeding the cookie value into the "hash" method we should
// be able to generate a hash that matches the one taken from the
// cookie. If they don't, we return null.
if
(
static
::
hash
(
$name
,
$value
)
===
$hash
)
if
(
static
::
hash
(
$name
,
$value
)
===
$hash
)
{
{
return
$value
;
return
$value
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment