简体   繁体   English

无法将Cookie设置为卷曲

[英]Unable to set the cookie in curl

I used this code to register the site.. But it shows "Your Session Expired, Please Login Again" 我使用此代码注册该网站。但是它显示“您的会话已过期,请重新登录”

It seems that I have some cookie Problem... but I don't understand what is the problem.. 看来我有一些Cookie问题...但是我不明白是什么问题。

and its not the full code. 而不是完整的代码。 I just posted the main part of it... 我刚刚发布了它的主要部分...

<?php
session_start();
$r=rand(1,999999999);
$cookie=$r;
$finalcookie="cookie/".$r.".txt";
$_SESSION['cookie']=$r;

$url="http://www.ypox.com";
$login="$url/content/login.html";
$signup="$url/content/signup.action";

$agent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0";          


$name="Arijit";
$email="dibbyo456@gmail.com";
$mobile="8798147385";
$cap="captcha";

$data="hidGen=Mr&tfUserName=$name&tfMobileNum=$mobile&tfUserID=$email&date1=10%2F10%2F1980&tfReferCode=&textcode=$cap&checkaccept=on";               

curl_setopt($ch, CURLOPT_URL, $signup);          
curl_setopt($ch, CURLOPT_USERAGENT, $agent);          
curl_setopt($ch, CURLOPT_COOKIEJAR,$finalcookie);          
curl_setopt($ch, CURLOPT_COOKIEFILE,$finalcookie);          
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);          
curl_setopt($ch, CURLOPT_POST, true);          
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);     
curl_setopt($ch, CURLOPT_REFERER, $login); 

$html=curl_exec($ch);
echo $html;

每个cookie都有一个唯一的会话ID。服务器使用该ID跟踪cookie。在您的代码中,您只发送了cookie的curl请求,但由于您手动生成cookie代码,因此cookie sessionid不在服务器上的记录中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM