So I have created this function called get_cookie. Right now it just returns the contents of that page. The code works, as when I echo the page, it shows I logged in successfully.
So I have 2 questions
- What do I need to put as the return value, in the - get_cookiefunction to get the cookie?
- How do I parse in a cookie when I make another request? 
<?php
function get_cookie($url, $username, $password) {
    $data = [
        "username"      => $username,
        "password"      => $password,
    ];
    $dataString = http_build_query($data);
    $ch = curl_init();
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($data));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $dataString);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
    return curl_exec($ch);
}
$url = "https://www.example.com/login";
$username = "user";
$password = "pass";
echo get_cookie($url, $username, $password);
?>
