无法在Perl中读取完整的cookie [英] Not able to read complete cookie in perl

查看:75
本文介绍了无法在Perl中读取完整的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从源系统接收以下cookie

I am receiving below cookie from my source system

ExternalAccess=unixtime=1593603710&oracletime=01-jul-20 
12:41:50_Hash_thNnmggU2ex3L5XXeMNfxf8Wl8STcVZTxscSFEKSxa0

在目标系统[基于PERL]上,使用以下代码读取cookie

At destination system [PERL based], using below code to read the cookie

my $extSysCookie = $Query->cookie('ExternalAccess');

我的输出低于输出

External Access cookie = unixtime=1593603710

,并且无法读取完整值。被省略。谁能帮忙?

and not able to read full value.All characters after & are getting omitted. Can anyone help?

推荐答案

首先,这不是有效的cookie。 Cookies的值中不允许有空格。 参考

First of all, that's not a valid cookie. Spaces are not allowed in the value of cookies. Ref.

第二,那就是不是CGI.pm的-> cookie 格式正确的cookie。 -> cookie 用于处理使用CGI.pm的-> cookie 创建的Cookie。有问题的Cookie值不是使用该方法创建的,并且该方法无法正确地处理Cookie。

Secondly, that's not a correctly formatted cookie for CGI.pm's ->cookie. ->cookie is designed to handle cookies created using CGI.pm's ->cookie. The cookie value in question was not created with that method, and the cookie can't be handled (correctly) by that method.

要从获取所需的字符串-> cookie ,或者使用-> cookie 构造cookie,或者使用URI编码的cookie来创建您希望的-> cookie 返回。

To get the desired string from ->cookie, either construct the cookie using ->cookie, or otherwise create a cookie with the URI-encoding the value you wish ->cookie to return.

例如,对于值为cookie的cookie将返回所需的字符串

For example, the desired string will be returned for a cookie with the value

unixtime%3D1593603710%26oracletime%3D01-jul-20%2012%3A41%3A50_Hash_thNnmggU2ex3L5XXeMNfxf8Wl8STcVZTxscSFEKSxa0

CGI的方法允许cookie具有多个值,并解决了cookie值中禁止使用空格的问题。

CGI's approach allows cookies to have multiple values, and gets around the problem of spaces being forbidden in the values of cookies.

这篇关于无法在Perl中读取完整的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆