Index.php File
<?php
session_start();
$username = $_POST['username'];
if(isset($username))
{
$_SESSION['id'] = $username;
echo "session working your username is ". $_SESSION['id'];
?>
<a href = "logout.php">Logout</a>
<?php
}
else
{
echo "Login first";
}
?>
<br><br>
<form action = "" method = "POST">
username: <input type = "text" name="username">
<input type= "submit">
</form>
Logout.php File
<?php
session_start();
session_destroy();
?>
<script>
window.location = 'index.php';
</script>
Choose the right course and start building your future with practical skills.
Learn HTML, CSS, JavaScript, and PHP to build modern, responsive websites and real-world projects.
Enroll Now See Full Details
Understand electronics basics with hands-on breadboard projects and circuit building techniques.
Enroll Now See Full Details
Step into AI with real-world applications, automation tools, and smart development techniques.
Enroll Now See Full Details