Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'vendor/autoload.php';
- $jar = new GuzzleHttp\Cookie\CookieJar();
- $default = [
- "cookies" => $jar
- ];
- $client = new \GuzzleHttp\Client(["defaults" => $default]);
- $username = "198604302009011002";
- $password = "xxx";
- $url_login = 'http://10.242.51.20/index.php/login';
- $login = $client->post( $url_login, [
- 'form_params' => [
- 'username' => $username,
- 'password' => $password,
- ],
- ]);
- $php = $login->getHeaders()['Set-Cookie'][0];
- $x = str_replace('PHPSESSID=', '', $php);
- $PHPSESSID = str_replace('; path=/', '', $x);
- $ci = $login->getHeaders()['Set-Cookie'][1];
- $y = str_replace('ci_session=', '', $ci);
- $z = explode('; expires=',$y);
- $ci_session = $z[0];
- $url_absensi = "http://10.242.51.20/index.php/absensi/lihat_absensi_user";
- $jar2 = new \GuzzleHttp\Cookie\CookieJar();
- $default2 = [
- "cookies" => $jar2
- ];
- $client2 = new \GuzzleHttp\Client();
- use \GuzzleHttp\Cookie\SetCookie;
- $t = time();
- $data = [
- 'Name' => 'PHPSESSID',
- 'Value' => $PHPSESSID,
- 'Path' => '/',
- 'Domain' => '10.242.51.20',
- 'Expires' => $t,
- 'Max-Age' => 100,
- 'Secure' => false,
- 'Discard' => false,
- 'HttpOnly' => false,
- ];
- $cookie2 = new SetCookie($data);
- $data2 = [
- 'Name' => 'ci_session',
- 'Value' => $ci_session,
- 'Path' => '/',
- 'Domain' => '10.242.51.20',
- 'Expires' => $t,
- 'Max-Age' => 100,
- 'Secure' => false,
- 'Discard' => false,
- 'HttpOnly' => false,
- ];
- $cookie3 = new SetCookie($data2);
- $cookieJar = new \GuzzleHttp\Cookie\CookieJar(
- false,
- [
- $cookie2,
- $cookie3
- ]
- );
- $client2 = new \GuzzleHttp\Client();
- $data_absensi = $client2->request('GET', $url_absensi,['cookies' => $cookieJar]);
- echo $data_absensi->getBody(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement