开发者

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

Is there any way to get CGI::开发者_如何学CSession to store the session id in something besides a cookie or a query string?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜