What is a Session?

What is a Session?

In PHP, a session is a way to store data and information. It allows the same information to be used across various pages. Sessions provide a simple way to store data for individual users against a unique session ID. They can be used to store information in between page requests.

A session creates a file in a temporary directory on the server. This is where registered session variables and their values are stored. This data will be available to all pages on the site during that visit. This is similar to a cookie; however, unlike a cookie, the information is not stored on the user’s computer, but rather on the server thus making the data safer.

The location of the temporary file is determined by a setting in the php.ini file called session.save_path. A new session can be started by using the session_start() function.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.