With cURL is really easy to handle cookies in both ways.
curl www.target-url.com -c cookie.txt
then will save a file named cookie.txt. But you need to log in, so need to use --data with arguments like: curl -X --data "var1=1&var2=2" www.target-url.com/login.php -c cookie.txt
.
Once you get loggued cookie you can send it with:
curl www.target-url.com/?user-page.php -b cookie.txt
Just use -c (--cookie) or -b (--cookie-jar) to save and send.
Note1: Using cURL CLI is a lot of easier than PHP and maybe faster ;)
For save the final content you can easily add > filename.html
to your cURL command then save full html code.
Note2 about "full": Yo cannot render javascript with cURL, just get the source code.