php - Login throw curl and browser -
i'm working drupal 7 , rest api. i'd log in drupal curl , later when visit website browser want logged in.
i'm usin gthis code:
<?php $user_data = array( 'username' => 'usertest', 'password' => 'pass', ); $ch = curl_init(); $tmpfname = dirname(__file__).'/'.$_cookie['phpsessid'].'.txt'; curl_setopt($ch, curlopt_url, "http://example.com/networklogin/user/login"); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $user_data); curl_setopt($ch, curlopt_returntransfer, true); curl_setopt( $ch, curlopt_cookiesession, true ); curl_setopt( $ch, curlopt_cookiejar, $tmpfname ); curl_setopt( $ch, curlopt_cookiefile, $tmpfname ); $response = curl_exec($ch); $http_code = curl_getinfo($ch, curlinfo_http_code); curl_close($ch); ?>
and works pretty well, logs user in, when visit "example.com" i'm not logget in "usertest". there way log me drupal , allow me access browser?
the goal log me in many website same users when log in 1 wrote here (same webserver, same drupal, same db, single sign on?).
ok, found solution here: login website through curl , client browser
use curl cookies user browser pretty impossible..
Comments
Post a Comment