I want to clear the session in a project. If i have opened an another project in the same browser, that session also cleared. How to clear the session without affecting the other projects?

try using unset()

Example:

<?php
    session_start();
    unset($_SESSION['username']);
    unset($_SESSION['user_id']);

    or 
    session_start();
    unset($_SESSION['username'], $_SESSION['user_id'])

?>

With this you could unset specific vars if needed. or you could

use session_unset();

to kill them all.

When I write logout scripts I use

<?php
    session_start();
    session_unset();
    session_destroy();

    header("Location: ". $_SERVER['HTTP_HOST']."/");
    exit;
?>

This should kill the session you've got running.

session_destroy();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.