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
4cf7f0c6
Commit
4cf7f0c6
authored
Jan 31, 2012
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added cookie jar that holds cookies until end of request.
parent
5a6f2f88
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
7 deletions
+52
-7
cookie.php
laravel/cookie.php
+36
-7
laravel.php
laravel/laravel.php
+16
-0
No files found.
laravel/cookie.php
View file @
4cf7f0c6
...
...
@@ -9,6 +9,13 @@ if (trim(Config::get('application.key')) === '')
class
Cookie
{
/**
* The cookies that have been set.
*
* @var array
*/
public
static
$jar
=
array
();
/**
* Determine if a cookie exists.
*
...
...
@@ -82,22 +89,44 @@ class Cookie {
*/
public
static
function
put
(
$name
,
$value
,
$minutes
=
0
,
$path
=
'/'
,
$domain
=
null
,
$secure
=
false
)
{
if
(
headers_sent
())
return
false
;
$time
=
(
$minutes
!==
0
)
?
time
()
+
(
$minutes
*
60
)
:
0
;
$_COOKIE
[
$name
]
=
static
::
sign
(
$name
,
$value
);
$_COOKIE
[
$name
]
=
$value
=
static
::
sign
(
$name
,
$value
);
// A cookie payload can't exceed 4096 bytes, so if the payload
// is greater than that, we'll raise an exception to warn the
// developer of the problem since it may cause problems with
// the application, especially if using cookie sessions.
if
(
strlen
(
$_COOKIE
[
$name
])
>
4000
)
// developer of the problem since it may cause bad problems.
if
(
strlen
(
$value
)
>
4000
)
{
throw
new
\Exception
(
"Payload too large for cookie."
);
}
return
setcookie
(
$name
,
$_COOKIE
[
$name
],
$time
,
$path
,
$domain
,
$secure
);
static
::
$jar
[
$name
]
=
compact
(
'name'
,
'value'
,
'time'
,
'path'
,
'domain'
,
'secure'
);
}
/**
* Send all of the cookies to the browser.
*
* @return void
*/
public
static
function
send
()
{
if
(
headers_sent
())
return
false
;
// All cookies are stored in the "jar" when set and not sent
// immediately to the browser. This just makes testing the
// cookie functionality of an application much easier, as
// the jar can be inspected by the developer.
foreach
(
static
::
$jar
as
$cookie
)
{
extract
(
$cookie
);
setcookie
(
$name
,
$value
,
$time
,
$path
,
$domain
,
$secure
);
}
}
/**
...
...
laravel/laravel.php
View file @
4cf7f0c6
...
...
@@ -181,6 +181,22 @@ if (Config::get('session.driver') !== '')
Session
::
save
();
}
/**
* Send all of the cookies to the browser. The cookies are
* stored in a "jar" until the end of a request, primarily
* to make testing the cookie functionality of the site
* much easier since the jar can be inspected.
*/
if
(
Config
::
get
(
'application.key'
)
!==
''
)
{
Cookie
::
send
();
}
/**
* Send the final response to the browser and fire the
* final event indicating that the processing for the
* current request is completed.
*/
$response
->
send
();
Event
::
fire
(
'laravel: done'
);
\ No newline at end of file
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