- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Understanding PHP sessions and cookies
Both PHP Sessions and Cookies are mechanism to store and retrieve data across multiple HTTP requests. But the purpose of storing the data and locations of storing are different.
Session values are stored on server-side. These values are stored to share common information across different pages. These values are lost once the browser closes.
Cookie values are stored on client-side or browser. These values are mainly user information. These values are saved permanently until cookie values deleted from the browser.
The pages where the session values are required must start the session using function session_start().
Session values are created using PHP Super Global Variable $_SESSION with a user-defined name.
$_SESSION["username"] = "john.doe@gmail.com";
Session values can be accessed using session variables.
echo $_SESSION["username"];
Session values can be deleted using function session_destroy().
On the other hand a cookie can be created using function setcookie().
setcookie("user", "John");
Cookie value can be accessed using PHP Super Global Variable $_COOKIE with the cookie name.
echo $_COOKIE["user"];
Cookie value can be deleted by setting a cookie expiration time in seconds. This cookie will be destroyed in one day or 86400 seconds.
setcookie("user", "John", 86400);
Both session and cookie are playing important role in web development.
Видео Understanding PHP sessions and cookies канала PHP Explained
Session values are stored on server-side. These values are stored to share common information across different pages. These values are lost once the browser closes.
Cookie values are stored on client-side or browser. These values are mainly user information. These values are saved permanently until cookie values deleted from the browser.
The pages where the session values are required must start the session using function session_start().
Session values are created using PHP Super Global Variable $_SESSION with a user-defined name.
$_SESSION["username"] = "john.doe@gmail.com";
Session values can be accessed using session variables.
echo $_SESSION["username"];
Session values can be deleted using function session_destroy().
On the other hand a cookie can be created using function setcookie().
setcookie("user", "John");
Cookie value can be accessed using PHP Super Global Variable $_COOKIE with the cookie name.
echo $_COOKIE["user"];
Cookie value can be deleted by setting a cookie expiration time in seconds. This cookie will be destroyed in one day or 86400 seconds.
setcookie("user", "John", 86400);
Both session and cookie are playing important role in web development.
Видео Understanding PHP sessions and cookies канала PHP Explained
Комментарии отсутствуют
Информация о видео
16 мая 2025 г. 8:30:11
00:01:21
Другие видео канала




















