Cakephp Classroom image

osdyui
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91|Last
Lessons:-Core Libraries

$id = $this->Auth->user(’id’);
If the current user is not logged in or the key doesn’t exist, null will be returned.
Cookie
class CookieComponent(ComponentCollection $collection, array $settings = array())
The CookieComponent is a wrapper around the native PHP setcookie method. It also includes a host
of delicious icing to make coding cookies in your controllers very convenient. Before attempting to use the
CookieComponent, you must make sure that ‘Cookie’ is listed in your controllers’ $components array.
Controller Setup
There are a number of controller variables that allow you to configure the way cookies are created and
managed. Defining these special variables in the beforeFilter() method of your controller allows you to
define how the CookieComponent works.
Cookie
variable
default
description
string
$name
‘Cake-
Cookie’
The name of the cookie.
string
$key
null This string is used to encrypt the value written to the cookie. This string should be
random and difficult to guess.
When using rijndael encryption this value must be longer than 32 bytes.
string
$domain
‘’ The domain name allowed to access the cookie. e.g. Use ‘.yourdomain.com’ to
allow access from all your subdomains.
int or
string
$time
‘5
Days’
The time when your cookie will expire. Integers are Interpreted as seconds and a
value of 0 is equivalent to a ‘session cookie’: i.e. the cookie expires when the
browser is closed. If a string is set, this will be interpreted with PHP function
strtotime(). You can set this directly within the write() method.
string
$path
‘/’ The server path on which the cookie will be applied. If $cookiePath is set to
‘/foo/’, the cookie will only be available within the /foo/ directory and all
sub-directories such as /foo/bar/ of your domain. The default value is the entire
domain. You can set this directly within the write() method.
boolean
$secure
false Indicates that the cookie should only be transmitted over a secure HTTPS
connection. When set to true, the cookie will only be set if a secure connection
exists. You can set this directly within the write() method.
boolean
$httpOnly
false Set to true to make HTTP only cookies. Cookies that are HTTP only are not
accessible in Javascript.
The following snippet of controller code shows how to include the CookieComponent and set up the controller
variables needed to write a cookie named ‘baker_id’ for the domain ‘example.com’ which needs a
secure connection, is available on the path ‘/bakers/preferences/’, expires in one hour and is HTTP only:
public $components = array(’Cookie’);
public function beforeFilter() {
parent::beforeFilter();

 
 
 

osdyui

Skills    Cakephp

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)