Not able to read complete cookie in perl

天大地大妈咪最大 提交于 2020-07-03 13:01:41

问题


I am receiving below cookie from my source system

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

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

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

i am getting below output

External Access cookie = unixtime=1593603710

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


回答1:


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

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.

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.

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's approach allows cookies to have multiple values, and gets around the problem of spaces being forbidden in the values of cookies.



来源:https://stackoverflow.com/questions/62676201/not-able-to-read-complete-cookie-in-perl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!