O'Reilly logo

PHP for Teens by Maneesh Sethi

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

Using Sessions

To start a session, you only need to use one function: session_start(). It automatically checks to see if a session is already running on your browser and, if not, assigns a new session ID. If a session is already running, it joins that session and uses it on the current page. A session ID is simply a sequence of numbers assigned to your computer when you start a session. Each computer gets a different session ID; it helps the web server keep track of who is doing what on the web site and inside the session.

session_start() must be placed before any other echoed HTML or test. This is exactly the same thing that happened with setcookie() in Chapter 12. Because sessions deal with the document header, the function pertaining to them ...

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