PHP 与cURL 代理 - 如何制作多用户 cookie jar?
我正在开发一个应用程序,它可以通过 cURL 进行远程登录等。
远程站点给出一个会话 cookie,我可以将其存储在我的 cookie 罐中。
我希望访问我站点的每个用户都能在远程站点上拥有唯一的会话。我的应用程序仅适用于一个用户(我),但我不确定如何使其成为多用户。
我的第一个想法是为我的应用程序用户设置一个会话变量,然后使用该变量作为 cookie jar 的名称,但这看起来很难看。
是否有任何内置 PHP/cURL 功能可以将唯一会话从远程服务器传递给我的用户?
非常感谢您的帮助。
杰克
I'm developing an application that does a remote login, amongst other things, via cURL.
The remote site gives out a session cookie, which I can store in my cookie jar.
I want each user to my site to have a unique session on the remote site. My application works fine with just one user (me), but I'm not sure how to make it multiuser.
My first thought is to set a session variable for my application users, then use this variable as the name of the cookie jar, but this seems ugly.
Is there any built-in PHP/cURL functionality that will pass the unique session from the remote server to my users?
Many thanks for any help.
Jack
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的问题包含解决方案的每个要素,即 cookie jar 和会话。
当您向 CURL 提供 cookie jar 文件时,只需根据您的用户为其指定一个名称,例如:
重要:请务必隐藏该文件夹(可能将其存储在文档根目录之外)。
Your question has every element of a solution, namely cookie jar and sessions.
When you provide the cookie jar file to CURL simply give it a name according to your user, example:
Important: Be sure to hide that folder (maybe store it outside your document root).