O'Reilly logo

PHP Quick Scripting Reference by Mikael Olsson

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

CHAPTER 25

image

Sessions

A session provides a way to make variables accessible across multiple web pages. Unlike cookies, session data is stored on the server.

Starting a session

To begin a session the session_start function is used. This function must appear before any output is send to the web page.

<?php session_start(); ?>

The session_start function will set a cookie on the client’s computer containing an id used to associate the client with the session. If the client already has an ongoing session the function will resume that session instead of starting a new one.

Session array

With the session started the $_SESSION array can be used to store ...

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