PHP COOKIE CREATION - PHP LESSON 22 STUDENTSBLOG100 - Anna University Multiple Choice Questions

PHP COOKIE CREATION - PHP LESSON 22 STUDENTSBLOG100

PHP COOKIES:
Cookies are small files which will be stored in local computer.

PHP COOKIE SYNTAX:
setcookie(name, value, expire, path, domain, secure, httponly);

Name(Required)
The name of the cookie.

Value(Optional)
The value of the cookie. Assuming the name is 'cookiename', this value is retrieved through $_COOKIE['cookiename']

Expire(Optional)
The time the cookie expires.
.
Path(Optional)
The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie  is being set in.

Domain(Optional)
The domain that the cookie is available to. Setting the domain to 'www.example.com' will make the cookie available in the www subdomain and higher subdomains. Cookies available to a lower domain, such as 'example.com' will be available to higher subdomains, such as 'www.example.com'.

Secure(Optional)
Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client. When set to TRUE, the cookie will only be set if a secure connection exists. On the server-side, it's on the programmer to send this kind of cookie only on secure connection (e.g. with respect to $_SERVER["HTTPS"]).

httponly(Optional)
When TRUE the cookie will be made accessible only through the HTTP protocol. This means that the cookie won't be accessible by scripting languages, such as JavaScript.

PHP COOKIE CREATION PROGRAM:

Lesson 21  Previous | Main Page | Next  Lesson 23

No comments:

Post a Comment