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
65bbea81
Commit
65bbea81
authored
Jul 06, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put the Cookie class on a diet.
parent
d1f1c367
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
86 deletions
+1
-86
cookie.php
system/cookie.php
+1
-86
No files found.
system/cookie.php
View file @
65bbea81
...
...
@@ -2,91 +2,6 @@
class
Cookie
{
/**
* The cookie name.
*
* @var string
*/
public
$name
;
/**
* The cookie value.
*
* @var mixed
*/
public
$value
;
/**
* The number of minutes the cookie should live.
*
* @var int
*/
public
$lifetime
=
0
;
/**
* The path for which the cookie is available.
*
* @var string
*/
public
$path
=
'/'
;
/**
* The domain for which the cookie is available.
*
* @var string
*/
public
$domain
=
null
;
/**
* Indicates if the cookie should only be sent over HTTPS.
*
* @var bool
*/
public
$secure
=
false
;
/**
* Create a new Cookie instance.
*
* Note: Cookies can be sent using the Cookie::put method.
* However, the number of parameters that method requires
* is somewhat cumbersome. Instantiating a new Cookie class
* and setting the properties can be a little easier on the eyes.
*
* @param string $name
* @return void
*/
public
function
__construct
(
$name
,
$value
=
null
)
{
$this
->
name
=
$name
;
$this
->
value
=
$value
;
}
/**
* Create a new Cookie instance.
*
* @param string $name
* @return Cookie
*/
public
static
function
make
(
$name
,
$value
=
null
)
{
return
new
static
(
$name
,
$value
);
}
/**
* Send the current cookie instance to the user's machine.
*
* @return bool
*/
public
function
send
()
{
if
(
is_null
(
$this
->
name
))
{
throw
new
\Exception
(
"Attempting to send cookie without a name."
);
}
return
static
::
put
(
$this
->
name
,
$this
->
value
,
$this
->
lifetime
,
$this
->
path
,
$this
->
domain
,
$this
->
secure
);
}
/**
* Determine if a cookie exists.
*
...
...
@@ -107,7 +22,7 @@ class Cookie {
*/
public
static
function
get
(
$name
,
$default
=
null
)
{
return
(
array_key_exists
(
$name
,
$_COOKIE
))
?
$_COOKIE
[
$name
]
:
$default
;
return
Arr
::
get
(
$_COOKIE
,
$name
,
$default
)
;
}
/**
...
...
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