MemoryRefresh!

Http / Cookies   Cookies



Questions 1 Answers 0%

Pages   0 from 91
Questions   0 from 142

Reset


Cookies allow your application to store a small text file on client Web broweser.
<?php // Set a cookie on the client setcookie('hide_menu', '1'); if ($_COOKIE['hide_menu'] == 1) { echo 'Hide Menu'; } ?> You can provide an expiration time.
<?php setcookie('hide_menu', '1', 3600); // 1 hour ?> Cookies values must be scalar
<?php setcookie('hide_menu', array()); // Warning: setcookie() expects parameter 2 to be string
There are three more arguments:
<?php // path - where cookie will be accesible // domain - allowed domani // secure - the browser only send cookie in case of HTTPS setcookie('hide_menu', '1', 86400, '/path/', 'www.example.com', 1); // a day ?> You can create arrays using the same array.
<?php setcookie('test[0]', "foo"); setcookie('test[1]', "bar");
To delete a cookie, set time negative
<?php setcookie("hide_menu", false, -3600);
Keep in mind that the amount of storage available is severely limited therefore, use sessions instead. If you want to set cookie for another domain, it can not be done.

Related Pages

Headers
URL
Cookies
Sessions


0% 100%
 
 
0 pages 91 pages
1) How you set a cookie?




2) Is the following code valid? <?php setcookie('user', array('John', 'Smith'));




3) Is the following code valid? <?php setcookie('test[0]', "foo"); setcookie('test[1]', "bar");







Cookies allow your application to store a small text file on client Web broweser.
<?php // Set a cookie on the client setcookie('hide_menu', '1'); if ($_COOKIE['hide_menu'] == 1) { echo 'Hide Menu'; } ?> You can provide an expiration time.
<?php setcookie('hide_menu', '1', 3600); // 1 hour ?> Cookies values must be scalar
<?php setcookie('hide_menu', array()); // Warning: setcookie() expects parameter 2 to be string
There are three more arguments:
<?php // path - where cookie will be accesible // domain - allowed domani // secure - the browser only send cookie in case of HTTPS setcookie('hide_menu', '1', 86400, '/path/', 'www.example.com', 1); // a day ?> You can create arrays using the same array.
<?php setcookie('test[0]', "foo"); setcookie('test[1]', "bar");
To delete a cookie, set time negative
<?php setcookie("hide_menu", false, -3600);
Keep in mind that the amount of storage available is severely limited therefore, use sessions instead. If you want to set cookie for another domain, it can not be done.

References









Programming

Php
   
Regex
   
MySQL
   
Css
   
jQuery
   
Git
   


References