Chaitu
Chaitu

Reputation: 101

Perl Session management

I am using CGI::Session for session management in my Perl web application. I am able to create a session using the file session driver but I am unable to get the existing session and unable to access stored parameters of session.

I am trying to get existing session but it's creating new one and query string $CGISESSID both are same but $session here I am getting was different it's a totally new one so I am unable to get the stored parameters from session. Please help me to resolve this issue.

Thanks, Krishna

Upvotes: 0

Views: 2347

Answers (2)

Sherzod
Sherzod

Reputation: 31

If you are getting new session at each request, as others pointed out, you are not sending session id in the cookie. If you are using CGI.pm to handle your HTTP header, do this:

print $q->header(-cookie => $session->cookie);

If you are using CGI::Application for your Application framework, do this inside the setup() or cgiapp_init() (if you have it)

$self->header_add(-cookie => $session->cookie);

Or, you can use CGI::Session's own header(), which by default, uses' CGI::header method:

print $session->header()

Using CGI::Session's utilities (such as cookie and/or header) are recommended since they honor expiration settings for the cookie.

Upvotes: 3

Sukhbir Dhillon
Sukhbir Dhillon

Reputation: 11

Are you doing print $session->header() before printing the html content?

Upvotes: 0

Related Questions