<?php
$url = 'http://twitter.com/';
$urlTo = 'https://twitter.com/';
$_SESSION['username_or_email'] = 'Auto_gues';
$_SESSION['password'] = 'curlphpcool';
$post = '[username_or_email]=' . $_SESSION['username_or_email'] . '&password=' . $_SESSION['password'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $urlTo);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20100101 Firefox/10.0.2');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
echo $html = curl_exec($ch);
echo '<pre>'.print_r(curl_getinfo($ch),1).'</pre>';
curl_close($ch);
echo $html;
?>