PHP Tutorial

A web server programming language.

PHP Sessions

PHP Sessions

A session is a way to store information (in variables) to be used across multiple pages. Unlike a cookie, the information is not stored on the users computer.

Start a PHP Session

A session is started with the session_start() function.

Session variables are set with the PHP global variable: $_SESSION.

Note: The session_start() function must be the very first thing in your document. Before any HTML tags.

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics