shail
shail

Reputation: 3

Not able to read complete cookie in perl

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?

Upvotes: 0

Views: 103

Answers (1)

ikegami
ikegami

Reputation: 386501

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.

Upvotes: 1

Related Questions