lundi 3 novembre 2014

PHP curl login saves user cookie into folder, but wont stay alive with the user on subsites


Vote count:

0




What Im trying to do:


1) Using a Curl Remote Login, which uses accounts from another host.


For example: A user which is registered at http://www.zwinky.com with the credentials: Username: Daniel Password: Daniel123 uses his account to sign in on my site.


2) After this user signed in into my site, his cookies will get saved to my server.


For example: User Daniel logs into my site and his cookies daniel.txt will get saved on my server. http://ift.tt/1Ghj4yN


3) After successfully signing into my site with the account from http://www.zwinky.com i want to redirect the user to another site on my server, which gives the user a Form element to post this to the http://wwww.zwinky.com Server.


The problem with this is: The cookie gets succesfull saved into a Folder on my server, but after the redirect the user wont have the cookie stored to himself. Like after the user got redirected and fills out another form element which should get posted to the http://www.zwinky.com server, the zwinky server returns a error message: "User is not signed in".


How can the saved user cookie stay alive with the user on each subsite of my server? Its saved on my server.


My actual login script:



<?php
$Luser = "";
$Lpass = "";

if(isset($_POST['inputUsername']) && isset($_POST['inputPassword'])){
$Luser = $_POST['inputUsername'];
$Lpass = $_POST['inputPassword'];
$L_info = "http://ift.tt/1DRrE3h".$Luser."&password=".$Lpass;
$zwinky_login_file = file_get_contents($L_info, true);

if (substr($zwinky_login_file, 12, 1) == "u"){ $message = "Blank username!"; }
if (substr($zwinky_login_file, 12, 1) == "p"){ $message = "Blank password!"; }
if (substr($zwinky_login_file, 12, 1) == "w"){ $message = "Wrong user/pass combination!"; }
if (substr($zwinky_login_file, 12, 1) == "s"){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL , $L_info);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "tmp/".$Luser);
curl_setopt($ch, CURLOPT_COOKIEJAR, "tmp/".$Luser);
$response = curl_exec($ch);
curl_close($ch);

$_SESSION['inputUsername'] = $Luser;
$_SESSION['inputPassword'] = $Lpass;

header('Location: ../stores.html');
}
echo($message);
}
?>


Also I would love it, to check on each subsite of my webserver, if the user does contain a session or a cookie. Else he should get redirected to the login site.


I would be really thankfull for every help. Hope someone knows a way.



asked 49 secs ago







PHP curl login saves user cookie into folder, but wont stay alive with the user on subsites

Aucun commentaire:

Enregistrer un commentaire