PHP ; Uable to store $_POST data in Session

I am sending three different values using post method from python to php and in php I am getting all these three values in three different files and in each file I am storing these values in session. before accessing the posted data in php I am checking whether it is set or not using if statement. If that if statement is true that post data will be stored in session.

first of all I am sending user id and password from python script.

post1 = {'uid': em_info,'pas': pas_info}
post1 = urlencode(post1).encode("utf-8")
req1 = Request(url1, post1)

here I am getting these values in first php script login.php

session_start();
if(isset($_POST['uid']))
{
    
    $_SESSION['uid'] = $_POST['uid'];
    $email = $_POST['uid'];
    $password = $_POST['pas'];
    $newpassword = hash("sha256", $password);
    
    
    
    $checkUser1 = "SELECT * FROM users1 WHERE  userid = '$email' AND  password = '$newpassword'";
    $checkUserStatus1 = mysqli_query($conn,$checkUser1) or die(mysqli_error($conn));
    if(mysqli_num_rows($checkUserStatus1) > 0) 
    {
        
        
        
        
        echo 'Successful' ;
    
    }
    else{
        
        echo 'nothing';
    }

}

After that I am sending search from python to second php script search.php.

search_info = search.get()
post2 = {'search': search_info}
post2 = urlencode(post2).encode("utf-8")
req2 = Request(url2, post2)

here I am getting it in search.php

session_start()
    $search="";
    if (isset($_POST['search']))
    {
        
        $search= $_POST['search'];
        $_SESSION['search'] = $_POST['search'];
        
        
    }

After that I am sending msg from python to third php script message.php.

message = self.entry_field.get()
postdata = {'msg': message}
postdata = urlencode(postdata).encode("utf-8")
req = Request(url3, postdata)
req.add_header("Content-type", "application/x-www-form-urlencoded")

here is its php code

session_start();

if (isset($_POST['msg']) )
{
    $_SESSION['msg'] = $_POST['msg'];
   $msg = $_POST['msg'];
    
    
    
    
}

At the end in the last file I am getting all data which i stored in session and saving it into database

session_start();
if(isset($_SESSION['uid']) AND isset($_SESSION['search']) AND isset($_SESSION['msg']))
{
    $email = $_SESSION['uid'];
    $search = $_SESSION['search'];
    $msg = $_SESSION['msg'];
    if($msg != '')
    {
        $sendMessage = "INSERT INTO messages(sender,receiver,message) VALUES('$email','$search','$msg')";
        $sendMessageStatus = mysqli_query($conn,$sendMessage) or die(mysqli_error($conn));
    
    }
}

When I tried to print session data it shows null array

print_r($_SESSION);

output of above print statement is:

Array()

Session works properly when i stored values which are not post data. Don't know why it is not storing post data in session. If someone knows any solution of my problem please share Thank you.