PersistentSessions: Difference between revisions
m (2 revisions imported) |
m (Fix code formating errors, add syntax highlighting for perl.) |
||
Line 1: | Line 1: | ||
If you would like to alleviate the need to constantly log in every time you close your browser, you can make the sessions persistent by modifying the cookie set to record the session ID. In the file Elements/[[SetupSessionCookie]] modify this code (near the bottom): | If you would like to alleviate the need to constantly log in every time you close your browser, you can make the sessions persistent by modifying the cookie set to record the session ID. In the file Elements/[[SetupSessionCookie]] modify this code (near the bottom): | ||
<syntaxhighlight lang="perl" line='line'> | |||
if ( !$cookies{$cookiename} ) { | if ( !$cookies{$cookiename} ) { | ||
my $cookie = new CGI::Cookie( | my $cookie = new CGI::Cookie( | ||
-name | -name => $cookiename, | ||
-value = | -value => $session{_session_id}, | ||
-path | -path => $RT::WebPath, | ||
-secure = | -secure => ($RT::WebSecureCookies ? 1 :0), | ||
); | ); | ||
$r- | $r->headers_out->{'Set-Cookie'} = $cookie->as_string; | ||
} | } | ||
</syntaxhighlight> | |||
to add an 'expires' key: | to add an 'expires' key: | ||
<syntaxhighlight lang="perl" line='line'> | |||
if ( !$cookies{$cookiename} ) { | if ( !$cookies{$cookiename} ) { | ||
my $cookie = new CGI::Cookie( | my $cookie = new CGI::Cookie( | ||
-name | -name => $cookiename, | ||
-value = | -value => $session{_session_id}, | ||
-path | -path => $RT::WebPath, | ||
-secure = | -secure => ($RT::WebSecureCookies ? 1 :0), | ||
-expires = | -expires => '+1M', | ||
); | ); | ||
$r- | $r->headers_out->{'Set-Cookie'} = $cookie->as_string; | ||
} | } | ||
</syntaxhighlight> | |||
This particular setting makes the session good for one month. You can find out what time values are valid by looking at the CGI.pm documentation: [http://search.cpan.org/~lds/CGI.pm-3.25/CGI.pm#CREATING_A_STANDARD_HTTP_HEADER: http://search.cpan.org/~lds/CGI.pm-3.25/CGI.pm#CREATING_A_STANDARD_HTTP_HEADER%3A] | This particular setting makes the session good for one month. You can find out what time values are valid by looking at the CGI.pm documentation: [http://search.cpan.org/~lds/CGI.pm-3.25/CGI.pm#CREATING_A_STANDARD_HTTP_HEADER: http://search.cpan.org/~lds/CGI.pm-3.25/CGI.pm#CREATING_A_STANDARD_HTTP_HEADER%3A] |
Latest revision as of 06:15, 1 February 2020
If you would like to alleviate the need to constantly log in every time you close your browser, you can make the sessions persistent by modifying the cookie set to record the session ID. In the file Elements/SetupSessionCookie modify this code (near the bottom):
if ( !$cookies{$cookiename} ) {
my $cookie = new CGI::Cookie(
-name => $cookiename,
-value => $session{_session_id},
-path => $RT::WebPath,
-secure => ($RT::WebSecureCookies ? 1 :0),
);
$r->headers_out->{'Set-Cookie'} = $cookie->as_string;
}
to add an 'expires' key:
if ( !$cookies{$cookiename} ) {
my $cookie = new CGI::Cookie(
-name => $cookiename,
-value => $session{_session_id},
-path => $RT::WebPath,
-secure => ($RT::WebSecureCookies ? 1 :0),
-expires => '+1M',
);
$r->headers_out->{'Set-Cookie'} = $cookie->as_string;
}
This particular setting makes the session good for one month. You can find out what time values are valid by looking at the CGI.pm documentation: http://search.cpan.org/~lds/CGI.pm-3.25/CGI.pm#CREATING_A_STANDARD_HTTP_HEADER%3A
Be sure to look at the following two articles to help clean up your old sessions (a good idea, evidently, whether or not you're planning on using this patch):
- RT 3.8.8
For RT 3.8.8 version you need to edit the file $RTHOME/lib/RT/Interface/Web.pm. Look for the "sub SendSessionCookie" function and add the -expires key as stated above.
Tested on 3.8.7, file to modify is : /usr/share/request-tracker3.8/lib/RT/Interface/Web.pm (on a Debian/squeeze). -- jissouille
This was tested on RT 3.6.3, but I'm sure it would apply to most versions. -- JoeCasadonte I'm sure this should work for any version greater than 3.0.0 --RuslanZakirov