Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

Introduction to Sessions

  • On the web, a session refers to a series of related communications between a web client & web server over a specific period of time that are used to:
    • Link multiple HTTP transactions
    • Preserve data over multiple transactions
  • Data, or state, preserved between a series of related HTTP transactions is referred to as session data.
  • A client-side session is when session data is stored by the web client, typically using cookies.
  • A server-side session is when session data is stored by the web server, typically in a file, database, or in RAM.
  • A unique session ID, or SID, is generated by a web server for each new server-side session.
  • The SID is used by the server to:
    • Identify multiple HTTP transactions as being part of the same session
    • To access any data stored for the session
  • A client passes an SID to the server with each HTTP request via either:
    • Cookies
    • URL Parameter
  • PHP typically uses a cookie, known as a session cookie, to pass the SID of a session between the client & server with each HTTP request.
  • PHP stores session data in flat files in the directory specified by the session.save_path configuration directive.
  • session_start() either creates a new session or continues an existing session. If using cookie-based sessions, it must be called before any output is generated.
  • $_SESSION is a superglobal used to store all session data and can be used to store data of any type, including arrays and objects.
  • When a key/value pair is added to $_SESSION, the key's name is referred to as a session variable.
  • To set, get, or delete session variables, standard associative array square bracket syntax & the unset() construct are used on the $_SESSION superglobal.
  • There are a number of configuration directives related to sessions in 'php.ini':
    • session.cookie_lifetime – sets the expiration of a session cookie
    • session.cookie_domain – sets the domain a session cookie is valid for
    • session.cookie_path – sets the path a session cookie is valid for
    • session.use_cookies – sets that cookies should be used to transfer SIDs
    • session.use_trans_sid – sets that URL parameters should be used to transfer SIDs
    • session.use_only_cookies – can be used to enforce the use of cookies for transferring SIDs
  • Additional Resources:

Introduction to Sessions

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

Advanced PHP Training with MySQL