简体   繁体   English

发送带有PHP curl cookie文件的PHPSESSID

[英]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 the PHPSESSID cookie back to Server A along with its own unique session id 服务器B将此ID存储在会话中,将PHPSESSID cookie连同其自己的唯一会话ID发送回服务器A
Server A validates the recieved PHPSESSID 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 recieved PHPSESSID 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_cookiejarcurlopt_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_COOKIECURLOPT_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.

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