This maybe a newbie question. Basically I need to know how to use php to login to a site and manage the session. Usually a site will set cookies for this so I need to know how to manage those cookies. I'm sure its simple i just dont know how to do it yet and coulnd't find the right infos online. Thanks
You don't need to deal with cookies if you want to use a session, the PHP $_SESSION takes care of everything for you. //page1.php session_start(); // start using a session $_SESSION['myVar'] = 'Hello World!'; // set something in your session PHP: //page2.php session_start(); // start using a session if(isset($_SESSION['myVar'])){ print $_SESSION['myVar']; // will print your Hello World! }else{ print 'Ohh boy, I don\'t see my session variable'; } PHP: Simple as apple pie. Basically, on any page you want to use session data you need to first start the session by using session_start(), after that you simply set/get your session data from the $_SESSION array.
Sorry my question wasn't clear, i need to use PHP to log into a REMOTE site (not managed by me) to automate some tasks.
Try looking at the CURL library. http://www.php.net/manual/en/ref.curl.php CURL can basically emulate a browser and handle cookies (among other things).