[英]Sending the PHPSESSID with php curl cookie file
I have 2 servers, each of which establish unique sessions and need to communicate back and forth. 我有2个服务器,每个服务器建立唯一的会话,并且需要来回通信。 I need to send the
PHPSESSID
cookie and get back the unique session cookie from my other server. 我需要发送
PHPSESSID
cookie并从其他服务器上获取唯一的会话cookie。
The way this needs to work is this: 这种工作方式是这样的:
Server A sends a request with the
PHPSESSID
cookie服务器A发送带有
PHPSESSID
cookie的请求
Server B stores this id in a session, sends thePHPSESSID
cookie back to Server A along with its own unique session id服务器B将此ID存储在会话中,将
PHPSESSID
cookie连同其自己的唯一会话ID发送回服务器A
Server A validates the recievedPHPSESSID
cookie against the current session and sends back an okay response with the current session id and the unique session id from Server B服务器A针对当前会话验证收到的
PHPSESSID
cookie,并使用服务器B的当前会话ID和唯一会话ID发送回正常响应
Finally Server B checks that the recievedPHPSESSID
from Server A matches that of the one in its own session, and that the unique session id sent back from Server A still matches the one it sent at the beginning of the request.最终, 服务器B检查从服务器A接收到的
PHPSESSID
与自己的会话中的PHPSESSID
匹配,并且从服务器A发送回的唯一会话ID仍与在请求开始时发送的唯一会话ID匹配。
I'm using php cURL library along with curlopt_cookiejar
and curlopt_cookiefile
. 我正在使用带有
curlopt_cookiejar
和curlopt_cookiefile
php cURL库。 The problem I'm having is that I don't know how to send the PHPSESSID
using a cookie file. 我遇到的问题是我不知道如何使用Cookie文件发送
PHPSESSID
。 This is required to keep both the session ids persistent throughout the communication. 这是使两个会话ID在整个通信中保持不变所必需的。
See: http://www.php.net//manual/en/function.curl-setopt.php 请参阅: http : //www.php.net//manual/en/function.curl-setopt.php
Use CURLOPT_COOKIE
or CURLOPT_COOKIEFILE
option. 使用
CURLOPT_COOKIE
或CURLOPT_COOKIEFILE
选项。 You may also need to use CURLOPT_COOKIEJAR
to save the cookie from the request. 您可能还需要使用
CURLOPT_COOKIEJAR
从请求中保存cookie。
See http://www.php.net//manual/en/function.curl-setopt.php#87112 for example. 例如,请参见http://www.php.net//manual/zh/function.curl-setopt.php#87112 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.