O'Reilly logo

Core PHP Programming: Using PHP to Build Dynamic Web Sites by Leon Atkinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Random Identifiers

If you ever need to track users through a site, you will need to assign unique identifiers. In a database you can store all the information you know about the user and pass the identifier from page to page either through links or with cookies. You will have to generate these identifiers randomly, otherwise it is too easy for anyone to masquerade as a legitimate user. Fortunately, random identifiers are easy to generate.

Listing 15.11 illustrates how this works. A pool of characters to use in the session identifier is defined. Characters are picked randomly from the list to build a session identifier of the specified length. That identifier is used inside a link so that it is passed to the next page. This method works for any ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required