Function mysqli_insert_id($conn) returns the ID of the record just inserted into the Database
You must pass the key you're searching for, and the array you want to search as parameters to function array_key_exists(). This function returns a true or false. For example:
<?php
session_start();
if (array_key_exists("uname", $_COOKIE)){
$_SESSION["uname"] = $_COOKIE["uname"]
};
?>