![]() |
![]()
| ![]() |
![]()
NAMEOpenXPKI::Client::UI::SessionCookie - manage the (optionally encrypted) session cookie SYNOPSISmy $cookie = OpenXPKI::Client::UI::SessionCookie->new( cgi => $cgi, cipher => Crypt::CBC->new( -key => $cipher_key, -pbkdf => 'opensslv2', -cipher => 'Crypt::OpenSSL::AES', ), ); # decrypt cookie and fetch session ID my $sess_id = $cookie->fetch_id; # this might throw a decryption error # set session ID and create encrypted cookie $cookie->id($sess_id); $cookie->path(...); # optionally print $cgi->header( ... -cookie => $cookie->build, ); METHODSnewConstructor. Parameters
METHODSpathSet the cookie path (only relevant for "build"). idSet the session ID (only relevant for "build"). buildBuild the HTTP cookie string containing the encrypted session ID previously set via "id" and the path set via "path". If no cipher has been set the session ID will be stored unencrypted. fetch_idReads the (encrypted) cookie from the "CGI" instance, decrypts it and returns the session ID. Throws an error if the decryption fails. Returns "undef" if no cookie was found. _encryptEncrypt the given value. Returns the encrypted value if a cipher was configured, or the plain input value otherwise. Returns an empty string if no value was given. _decryptDecrypt the given value. Returns the decrypted value if a cipher was configured, or the plain input value otherwise.
|