Using Sessions Without Cookies

One of the problems with sessions is that, as it stands, they rely on the use of a cookie to work properly. When a session is started, it sends a cookie that resides in the user's Web browser, which contains the session name (Figure 5.21). Every subsequent page that calls session_start() makes use of the cookie to know to use an existing session and to not create a new one. The problem is that users may have cookies turned off in their Web browser or may not accept the cookie because they do not understand its purpose. If this is the case, PHP will create a new session for each page and none of the registered variables will be accessible.

You can use sessions without cookies by passing along the session name from ...

Get PHP Advanced for the World Wide Web: Visual QuickPro Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.