note 103322 deleted from function.http-post-fields by danbrown

From: Date: Thu, 07 Apr 2011 14:34:59 +0000
Subject: note 103322 deleted from function.http-post-fields by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178597@lists.php.net to get a copy of this message
Note Submitter: marcoigarapava at gmail dot com ---- Here's a good way to get cookies from a page and then resubimit the data to that page (or acess any other page using the cookies gotten). <?php //SOME DATA TO POST $postData = array ( 'user' => $login, 'pass' => $pass ); //FIRST POST $post1 = http_post_fields('http://example.com', $postData); //GET THE COOKIES STORED TO THE ARRAY $cookie preg_match('/Set-Cookie: (.*)\b/', $post1, $cookie); $cookie = (array) http_parse_cookie($cookie[1]); $cookie = array( 'cookies' => $cookie["cookies"]); //POST DATA NOW WITH THE COOKIE $post2 = http_post_fields('http://example.com', $postData, array(), $cookie); ?>

« previous php.notes (#178597) next »