Cookies are often used to identify users. Cookies are small files that the server stays in the user's computer. when the same computer requests a page through a browser, they send a cookie at the same time.
Cookies are often used to identify users. Cookies are small files that the server stays in the user's computer. when the same computer requests a page through a browser, they send cookies at the same time, you can create and retrieve the cookie value
Syntax:Setcookie (name, value, expire, path, domain );
- **
- * Set cookie
- * N name
- * C value
- * E validity period 0: one month by default; 1: disabled; expired immediately
- */
-
- Function w_cookie ($ n, $ c, $ e = 0, $ isdes = 1)
- {
- If ($ isdes = 1) {$ c = endes ($ c, Region EY );}
- $ Exp = time () + 3600*24*30;
- If ($ e = 0)
- {
- Setcookie ($ n, $ c, $ exp ,"/");
- }
- Else
- {
- Setcookie ($ n, $ c, 0 ,"/");
- }
- }
How to disable cookie:W_cookie ('BB ', 'www .phpfensi.com', $ e = 0, $ isdes = 1 );
The detailed method is as follows:
- Function set_cronology ($ name, $ value, $ duration = 7 ){
- $ Duration = time () + (3600*24 * $ duration );
- $ Max_stored_values = 5;
- If (isset ($ _ cookie [$ name]) {
- Foreach ($ _ cookie [$ name] as $ prop_crono => $ val_crono ){
- If ($ val_crono = $ value)
- Return;
- }
- If ($ prop_crono <$ max_stored_values)
- Setcookie ($ name. '['. ($ prop_crono + 1). ']', $ value, $ duration );
- Else {
- Array_shift ($ _ cookie [$ name]);
- Setcookie ("$ name [$ max_stored_values]", $ value, $ duration );
- }
- } Else
- Setcookie ($ name. '[0]', $ value, $ duration );
- Return;
- }
- ?>
Note:The setcookie () function must be locatedBefore the tag is sent, the cookie value is automatically url encoded and automatically decoded during retrieval (to prevent url encoding, use setrawcookie () instead ).