简体   繁体   English

如何在Firefox和Perl之间自动化和共享会话?

[英]How can I automate and share sessions between Firefox and Perl?

Is it possible to do part of a web flow in Perl and then transfer the rest of the session to Firefox? 是否可以在Perl中执行Web流的一部分,然后将剩余的会话转移到Firefox?
I need to retry(with Perl) logging in to a website which returns 500 every now and then on a successful login, transfer the authenticated session to Firefox, from where I can continue my normal browsing. 我需要重试(使用Perl)登录到一个网站,该网站每次都会返回500,然后成功登录,将经过身份验证的会话转移到Firefox,我可以继续正常浏览。 Is this possible? 这可能吗?
If this is possible, how do I do it? 如果可以,我该怎么办? Can you point me to some resources on how can transfer the cookie/session, etc ? 你能指点我一些关于如何转移cookie /会话的资源吗?

To me, it seems that it makes more sense to do everything from within Firefox ... and control that from the outside. 对我来说,似乎从Firefox中做所有事情更有意义......并从外部控制它。 MozRepl (the FF extension) and MozRepl (the Perl module) may help you in getting there. MozRepl (FF扩展)和MozRepl (Perl模块)可以帮助您实现目标。

Tricky. 棘手。 You will not be able to have your server log in to the 3rd party service, and then just serve up the session cookie to your user, and redirect him to the 3rd party app. 您将无法让您的服务器登录到第三方服务,然后只是向您的用户提供会话cookie,并将其重定向到第三方应用程序。 This will not work because cookies are domain specific, and domains cannot access cookies from or set by another domain. 这不起作用,因为cookie是特定于域的,域不能访问其他域的cookie或由其他域设置。

So your service will need to act as an interface to the third party service, and as such you will need to maintain a user session on your server. 因此,您的服务需要充当第三方服务的接口,因此您需要在服务器上维护用户会话。 This user session keeps track of your user, will log in to third party service, and will make requests to the 3rd party service when appropriate. 此用户会话会跟踪您的用户,将登录到第三方服务,并在适当时向第三方服务发出请求。 The session on your server will be an http client for this 3rd party service, so it will need to be able to handle cookies correctly - ie mimic a browser. 您服务器上的会话将是此第三方服务的http客户端,因此它需要能够正确处理cookie - 即模仿浏览器。

In terms of setting up and maintaining user sessions, there will be a number of CPAN modules to help you with this. 在设置和维护用户会话方面,将有许多CPAN模块可以帮助您完成此任务。

For more info on managing user sessions in Perl, see 有关在Perl中管理用户会话的更多信息,请参阅 https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-1044683.html https://web.archive.org/web/1/http://articles.techrepublic%2ecom%2ecom/5100-10878_11-1044683.html

Edit: some web services can manage user sessions by injecting a session id into the URL when the client refuses cookies. 编辑:一些Web服务可以通过在客户端拒绝cookie时将会话ID注入URL来管理用户会话。 If your 3rd party service will do this, you could maybe just serve up the login response URL as a redirect to your user. 如果您的第三方服务会执行此操作,您可以将登录响应URL作为重定向提供给您的用户。 However, this will break if sessions are bound to an IP. 但是,如果会话绑定到IP,则会中断。

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

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