如何获取会话ID并将其插入到产品ID旁边的数据库中

I am trying to get session id from a user that logs in and insert it into database next to id of a product that user ordered. I'm new to php, so i dont know how to get this id, it somehow always shows 0 in database. Here is the code:

This is the starting code of the page, session is supposed to be taken from a login.inc.php file

    session_start();
    include "includes/dbh.inc.php"; 
    $id = isset($_GET['id']) ? $_GET['id'] : '';
    $sql = "SELECT * FROM tbl_product WHERE id = ". $id;
    $result = mysqli_query($conn, $sql);
    $u_id = isset($_SESSION['u_id']);

Here is the code that should insert products into table user_korpa

if (isset($_POST['dodajukorpu'])) {
        while ($row = mysqli_fetch_assoc($result)) { 
            $id = $row['id'];
            $name = $row['name'];
            $image = $row['image'];
            $price = $row['price'];
            $tip = $row['tip_proizvoda'];
            $sql = "INSERT INTO user_korpa (p_id, u_id, name, image, price, tip_proizvoda) VALUES ('$id','{$_SESSION['u_id']}','$name','$image','$price','$tip')";
            $result2 = mysqli_query($conn, $sql);