Lee Wang
Lee Wang

Reputation: 81

How can I make CGI::Session store session data on the server side using Perl?

Is there any way to get CGI::Session to store the session id in something besides a cookie or a query string?

Upvotes: 1

Views: 492

Answers (2)

GeneQ
GeneQ

Reputation: 7595

You can ask CGI::Session to persist session data in a database of your choice. For MySQL, you can do it like so:

use CGI::Session;
$session = new CGI::Session("driver:MySQL", undef, {Handle=>$dbh});

See CGI::Session::MySql for details.

Upvotes: 0

Andrey Adamovich
Andrey Adamovich

Reputation: 20663

Storing session id in the cookie or in the query string are the only 2 ways HTTP protocol allows to transfer session id on each and every request. If you store it somewhere else, then there is no way for the client and server to know they are working with the same session.

Upvotes: 3

Related Questions