manual/en/features.cookies.php
20131002_rev01 · COMPARED WITH 20130923_rev01 · ARCHIVE SNAPSHOT, DATE APPROXIMATE
Full text changes — 20130923_rev01 to 20131002_rev01
| 33 | 33 | **5 months ago** |
| 34 | 34 | |
| 35 | 35 | `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 | 36 | |
| 37 | 37 | 2 |
| 38 | 38 | |
| 39 | [**_meetyashah at gmail dot com_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) | |
| 39 | [**_mega-squall at caramail dot com_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) | |
| 40 | 40 | |
| 41 | **5 months ago** | |
| 41 | **8 years ago** | |
| 42 | 42 | |
| 43 | `PAGE 1` | |
| 43 | `I found a solution for protecting session ID without tying them to client's IP. Each session ID gives access for only ONE querry. On the next querry, another session ID is generated and stored. If somebody hacks the cookie (or the session ID), the first one of the user and the pirate that will use the cookie will get the second disconnected, because the session ID has been used.` | |
| 44 | 44 | |
| 45 | `<?php echo $_COOKIE["first"]; ?> PAGE 2` | |
| 45 | `If the user gets disconnected, he will reconnect : as my policy is not to have more than one session ID for each user (sessions entries have a UNIQUE key on the collomn in which is stored user login), every entries for that user gets wiped, a new session ID is generated and stored on users dirve : the pirate gets disconnected. This lets the pirate usually just a few seconds to act. The slower visitors are browsing, the longer is the time pirates get for hacking. Also, if users forget to explicitly end their sessions .... some of my users set timeout longer than 20 minutes !` | |
| 46 | 46 | |
| 47 | `<?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"]; } ?>` | |
| 47 | `IMPORTANT NOTE : This disables the ability of using the back button if you send the session ID via POST or GET.` | |
| 48 | 48 | |
| 49 | 49 | 2 |
| 50 | 50 | |
| 51 | [**_mega-squall at caramail dot com_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) | |
| 51 | [**_meetyashah at gmail dot com_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) | |
| 52 | 52 | |
| 53 | **8 years ago** | |
| 53 | **5 months ago** | |
| 54 | 54 | |
| 55 | `I found a solution for protecting session ID without tying them to client's IP. Each session ID gives access for only ONE querry. On the next querry, another session ID is generated and stored. If somebody hacks the cookie (or the session ID), the first one of the user and the pirate that will use the cookie will get the second disconnected, because the session ID has been used.` | |
| 55 | `PAGE 1` | |
| 56 | 56 | |
| 57 | `If the user gets disconnected, he will reconnect : as my policy is not to have more than one session ID for each user (sessions entries have a UNIQUE key on the collomn in which is stored user login), every entries for that user gets wiped, a new session ID is generated and stored on users dirve : the pirate gets disconnected. This lets the pirate usually just a few seconds to act. The slower visitors are browsing, the longer is the time pirates get for hacking. Also, if users forget to explicitly end their sessions .... some of my users set timeout longer than 20 minutes !` | |
| 57 | `<?php echo $_COOKIE["first"]; ?> PAGE 2` | |
| 58 | 58 | |
| 59 | `IMPORTANT NOTE : This disables the ability of using the back button if you send the session ID via POST or GET.` | |
| 59 | `<?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"]; } ?>` | |
| 60 | 60 | |
| 61 | 61 | 0 |
| 62 | 62 | |
| 63 | 63 | [**_myfirstname at braincell dot cx_**](http://www.php.net/manual/en/features.cookies.php) [¶](http://www.php.net/manual/en/features.cookies.php) |
| 64 | 64 | |
| 65 | **9 years ago** | |
| 65 | **10 years ago** | |
| 66 | 66 | |
| 67 | 67 | `[Editor's note: Wilson's comment has been deleted since it didn't contain much useful information, but this note is preserved although its reference is lost]` |
| 68 | 68 | |
| 69 | 69 | `Just a general comment on Wilton's code snippet: It's generally considered very bad practice to store usernames and/or passwords in cookies, whether or not they're obsfucated. Many spyware programs make a point of stealing cookie contents.` |
| 70 | 70 | |
| 71 | 71 | `A much better solution would be to either use the PHP built in session handler or create something similar using your own cookie-based session ID. This session ID could be tied to the source IP address or can be timed out as required but since the ID can be expired separately from the authentication criteria the authentication itself is not compromised.` |