Hello
In this video, we will learn
How to use PHP Session and Redirect
How to use redirection in #phpscripts
Login Code in PHP with Session and Redirection
What is Session in PHP?
Session in PHP is a way of temporarily storing and making data accessible across all the website pages.
What Is the Use of Session in PHP?
A session in PHP allows the webserver to get information about when you started a website, what you were doing, when you closed the website, and other related information. It is required because, unlike the PC or mobile, the web server does not have any information about you. That’s where sessions come into the picture.
These sessions have session variables that store all the necessary information in a temporary file. By default, it will destroy this file when you close the website. Thus, to put it simply, a session in PHP helps in storing information about users and makes the data available to all the pages of a website or application until you close it.
To create a Session variable
//STEP1:
session_start();
//STEP2:
$_SESSION["loggedin-user"] = "Raj";
Here $_SESSION["loggedin-user"] is the Session variable and Raj is its value
//STEP3:
To check whether the variable is created or not
if (!isset($_SESSION["loggedin-user"])) {
header("Location: login.php"); //redirection
}
the isset() can be used to check whether the Session Variable has been created or not.
Watch video How to use PHP Session and Redirect in Login | online without registration, duration hours minute second in high quality. This video was added by user Software Services and Solutions 04 May 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 65 once and liked it 1 people.