I tried to create a button which removes existing cookies and saves other data using this
    <?php session_start(); ?>
<html>
    <head>
        <title>Reading Cookies</title>
    </head>
    <body>
        <?php // Reading the value of a cookie
            // give $var1 a default value
            $var1 = 'cookie not set';
            $var2 = 'unspecified';
            // if cookie with name 'test' exists then set $var1 to its value
            if (isset($_COOKIE['id'],$_COOKIE['usr'])) {
                $var1 = $_COOKIE['id'];
                $var2 = $_COOKIE['usr'];
            }
            echo "id= {$var1}<br/>usr= {$var2}";
        ?>
        <?php // Deleting a cookie
            // set cookie value to 0 and expiration to the distant past
            if(isset($_GET['logout'])) {
            setcookie('usr', null, time()-(60*60*24*7));
            setcookie('id', null, time()-(60*60*24*7));
            $_SESSION['first_name'] = "aa";
            $_SESSION['last_name'] = "bb";
            }
         ?>
         <br/>
         <a href="?logout">logout</a>
    </body>
</html>
but when I try to access the first_name and last_name valus via other page
<?php session_start();
        // read values from the session
        $name = $_SESSION['first_name'] . " " . $_SESSION['last_name'];
        echo $name;
    ?>
it displays error undefined index first_name
