manual/en/features.cookies.php
20130822_rev01 · COMPARED WITH 20130702_rev01 · ARCHIVE SNAPSHOT, DATE APPROXIMATE
Full text changes — 20130702_rev01 to 20130822_rev01
| 1 | Change language: | |
| 2 | ||
| 3 | PHP transparently supports HTTP cookies. Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users. You can set cookies using the [setcookie()](http://www.php.net/manual/en/function.setcookie.php) or [setrawcookie()](http://www.php.net/manual/en/function.setrawcookie.php) function. Cookies are part of the HTTP header, so [setcookie()](http://www.php.net/manual/en/function.setcookie.php) must be called before any output is sent to the browser. This is the same limitation that [header()](http://www.php.net/manual/en/function.header.php) has. You can use the [output buffering functions](http://www.php.net/manual/en/ref.outcontrol.php) to delay the script output until you have decided whether or not to set any cookies or send any headers. | |
| 4 | ||
| 5 | Any cookies sent to you from the client will automatically be included into a [$\_COOKIE](http://www.php.net/manual/en/reserved.variables.cookies.php) auto-global array if [variables\_order](http://www.php.net/manual/en/ini.core.php) contains "C". If you wish to assign multiple values to a single cookie, just add _\[\]_ to the cookie name. | |
| 6 | ||
| 7 | Depending on [register\_globals](http://www.php.net/manual/en/ini.core.php), regular PHP variables can be created from cookies. However it's not recommended to rely on them as this feature is often turned off for the sake of security. $HTTP\_COOKIE\_VARS is also set in earlier versions of PHP when the [track\_vars](http://www.php.net/manual/en/ini.core.php) configuration variable is set. (This setting is always on since PHP 4.0.3.) | |
| 8 | ||
| 9 | For more details, including notes on browser bugs, see the [setcookie()](http://www.php.net/manual/en/function.setcookie.php) and [setrawcookie()](http://www.php.net/manual/en/function.setrawcookie.php) function. | |
| 10 | ||
| 1 | 11 | 6 |
| 2 | 12 | |
| 3 | 13 | [**_ingen at stocken.ws_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) |
| 4 | 14 | |
| 5 | 15 | **6 years ago** |
| 6 | 16 | |
| 27 | 37 | `* You could use session_set_save_handler and make sure the session ID is generated in the open function. I haven't done that so I can't make any comments on it yet.` |
| 28 | 38 | |
| 29 | 39 | 1 |
| 30 | 40 | |
| 31 | 41 | [**_Anonymous_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) |
| 32 | 42 | |
| 33 | **2 months ago** | |
| 43 | **4 months ago** | |
| 34 | 44 | |
| 35 | 45 | `Your note is too short. Trying to test the notes system? Save us the trouble of deleting your test, and don't. It works.` |
| 36 | 46 | |
| 37 | 47 | 1 |
| 38 | 48 | |
| 39 | 49 | [**_mega-squall at caramail dot com_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) |
| 47 | 57 | `IMPORTANT NOTE : This disables the ability of using the back button if you send the session ID via POST or GET.` |
| 48 | 58 | |
| 49 | 59 | 0 |
| 50 | 60 | |
| 51 | 61 | [**_meetyashah at gmail dot com_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) |
| 52 | 62 | |
| 53 | **2 months ago** | |
| 63 | **3 months ago** | |
| 54 | 64 | |
| 55 | 65 | `PAGE 1` |
| 56 | 66 | |
| 57 | 67 | `<?php echo $_COOKIE["first"]; ?> PAGE 2` |
| 58 | 68 | |
| 59 | 69 | `<?php if(isset($_COOKIE["first"])) { echo $_COOKIE["first"];} echo '<br />'; if(isset($_COOKIE["second"])){ echo $_COOKIE["second"]; } echo '<br />'; if(isset($_COOKIE["third"])){ echo $_COOKIE["third"]; } ?>` |