Everything About PHP Sessions

A complete course about handling persistent PHP sessions storing them into database securely and auto login system
4.4 (12 ratings)
Instead of using a simple lifetime average, Udemy calculates a
course's star rating by considering a number of different factors
such as the number of ratings, the age of ratings, and the
likelihood of fraudulent ratings.
99 students enrolled
Take This Course
  • Lectures 25
  • Length 3.5 hours
  • Skill Level Intermediate Level
  • Languages English
  • Includes Lifetime access
    30 day money back guarantee!
    Available on iOS and Android
    Certificate of Completion
Wishlisted Wishlist

How taking a course works


Find online courses made by experts from around the world.


Take your courses with you and learn anywhere, anytime.


Learn and practice real-world skills and achieve your goals.

About This Course

Published 10/2015 English

Course Description

PHP tireless sessions allow for communication between the server and client. This allows web applications to remember the identities of visitors as well as any variables or other data. This practical and challenging project-based course will help developers take the data that PHP normally stores in plain text files and write them into a more secure database, where the records can be read and destroyed as needed. I help you set up a SQL database, define classes to open and close sessions, read and write variables, destroy sessions, and manage out-of-date records. The lessons culminate in a short project that uses tokens to recognize returning users in an auto-login scenario.

In this course:

  • I'll show you how to store session in data in a MySQL database
  • How to log in returning users automatically
  • We'll begin with an overview of how PHP handles Sessions and stores session data in plain text files on the web server
  • We'll set up a database to store session data more securely
  • I'll show you how to define a class to open and close sessions
  • Read and write session variables to the database
  • Destroy sessions and garbage collect out-of-date records

Sessions expire as soon as soon as the browser is closed, but the highlight of this course is an auto-login system that uses a randomly generated single use token that recognizes returning users and preserves their data between visits, even on different computers. I hope you'll find this a useful and challenging project.

keeping the user's data always up to date with persistent sessions is extremely convenient. But, and I can't stress this strongly enough, persistent sessions are not 100 percent secure. When using sessions, you should always use a connection over secure sockets layer, or transport layer security whenever possible. I’m going to talk about why always re-authenticate user credentials before allowing allowing access to pages with sensitive content, such as changing user account details.

What are the requirements?

  • This is not a beginner's course, so you need to have a solid grasp of PHP syntax, including the use of control structures, loops, and arrays.
  • You should also be comfortable working with PHP classes and objects. Nearly all of the code in this course is object oriented.
  • You should understand basic SQL for select, insert, update, and delete queries.
  • A lot of the code uses PDO-prepared statements with named parameters to submit queries to the database, so you should be familiar with using PDO.
  • You need to know HTML and a little CSS

What am I going to get from this course?

  • Configure PHP sessions to make them persistent
  • Inspect how session data is stored
  • Implement persistent sessions
  • Create a SQL database to store session data
  • Implement the PHP SessionHandlerInterface
  • Write session data
  • Close and destroying sessions
  • Create an auto-login system with persistent sessions
  • Create persistent logins
  • Checkout visitor credentials
  • Authenticate users
  • Log out users selectively

Who is the target audience?

  • If you want to know how to store session in data in a Mysql or MariaDB database
  • If you want to know how to log in returning users automatically
  • If you want to know how to define a class to open and close sessions
  • If you want to know how to read and write session variables to the database
  • If you want tot know how to destroy sessions and garbage collect out-of-date records

What you get with this course?

Not for you? No problem.
30 day money back guarantee.

Forever yours.
Lifetime access.

Learn on the go.
Desktop, iOS and Android.

Get rewarded.
Certificate of completion.


Section 1: Introduction
Section 2: Security and Sessions
Security and Sessions
Session Configurations
Changing Configurations
Session Inspection
Session Implementation
Section 3: Database for Sessions
Database Setup
Create Database Tables
Connect to Database
Section 4: Storing Session Data in Database
Session Handler Interface
Open and Read Methods
Write Method
Close Method
Destroy Session
Using Session Handler
Section 5: Building an Autologin System
How Auto Login System Works?
Using Trait
Persistent Session Handler
Auto Login Class
Auto Login Helpers
Logging Out
Section 6: Testing
User Registration
PSR-4 Auto Loader
User Auto Authentication
Extra Files

Students Who Viewed This Course Also Viewed

  • Loading
  • Loading
  • Loading

Instructor Biography

Hassan Azimi, Software Engineer and Web Developer

Hi My name is Hassan Azimi and I am a software engineer and a web developer. My second job is to produce videos about technology and computers for people all over the world. I have first class degree with Honours one of the top universities in London and I am working towards the best technologies about software, coding and he web. I understand most of the programming languages mainly web based languages. I continuously enjoy learning new technologies exclusively programming languages by watching tutorials instead of reading books and this is not mean I don't read books at all. Subsequently, reading a lot of books about computers and watching more video lectures about programming and web developing, I educated a lot of new subjects and I decided to make the professional tutorials. I am obsessed with everything about computers and fascinated by everything about programming which leads me to build things like a puzzle. By reading books I noticed they do not have that impression, sense and excitement similar to videos. I do not mean they are useless, what I mean is they are far away from fun, practical, excitement and walking through each lesson. I noticed something else and that was lack of video tutorials about computing for Persians and Farsi speaking people and that must be because of low Internet speed and Internet censorship. I found Udemy is not censored in Iran but YouTube is and that was a great news for me, which made my students asking me to find a way to allow them to download my videos. I am sure some people do not learn only by reading as some people do. Most people who computing is their career are practical people rather than people with humanity subjects, one them is myself. I am a practical person, I learn by watching. Therefore, I decided to make video tutorials. Today I am the only best Persian tutorial source for all Persians and the only one who makes really professional tutorials with great video and audio quality. If you watch my tutorials you will notice I really care about every single video tutorials I make and I have so much respect to Udemy academy which I think it is one of the best ideas.

Ready to start learning?
Take This Course