1- how to create the session
session_start(); // this function must always set in every page among website
// now we conect to database
$con=mysql_connect('localhost','root');
if(! $con) die ("no localhost");
$db=mysql_select_db('school',$con);
if(! $db) die ("no db");
// this code will check if the login buuton was clicked and get the id , password of the user and chek if the password is correct and met the id
if(isset($_POST['submit']))
{
$id=$_POST['id'];
$pass=$_POST['pass'];
if($pass=="" || $id=="")
{
header('location:../index.php?value=خطا في رقم المستخدم او كلمة المرور ');
exit;
}
// if the id and password are correct we save the id in the session to take it with us to any page we visit through website
else
{
$_SESSION['aid']=$id;
header('location:../admin/adminform.php');
}
2- how to kill the sesion (its very simlpe code)
<?php
session_start();
session_unset();
session_destroy();
header("location:index.php");
?>