Open Telegram channel - https://t.me/PHPnoob
PHP Help Chat - https://t.me/php_noob
In this video, we'll take a detailed look at how COOKIES and SESSIONS work in PHP. We'll learn why cookies and sessions are used. We'll also explore their main differences and provide usage examples. We'll also cover using secure cookie flags (HttpOnly, Secure). Configuring session lifetimes based on security requirements. We'll create a simple user login form and banner rotation using COOKIES.
COOKIES should store data that is safe to disclose to the user, while SESSIONS should store authentication information. Sessions don't work separately from cookies, but rather complement them to ensure more secure storage of user data on the server.
Sessions are stored on the server, while the client (browser) stores only a unique session ID. COOKIES are stored client-side, in the user's browser. 00:00 What is an HTTP COOKIE (web cookie)
01:24 How is COOKIE data initialized?
03:40 The $_COOKIE array in PHP
04:00 The setcookie function in PHP for setting cookie data
07:00 Parameters of the setcookie function
11:00 The $path parameter in the setcookie function: how it works and what to specify
12:00 The httpOnly parameter in the PHP setcookie function
14:00 Creating basic banner rotation using cookies
18:00 Basic user authentication using cookies and the problems with this approach
20:00 Implementing authentication using PHP's built-in session mechanism
23:00 Setting the session lifetime using ini_set
26:00 Destroying session data and logging out a user
#training #programming #php