Solved

delete session in perl

Posted on 2013-12-24
4
709 Views
Last Modified: 2013-12-28
hi all,

i am using the next code to delete the session ... my problem that i can enter the link

on the url address  after doing logout.... this mean that the session is stell a live!

use CGI::Session qw/-ip-match/;

#$sid = $cgi->cookie('CGISESSID') || $cgi->param('CGISESSID') || undef;
$sid = param('CGISESSID') || undef;
$session = new CGI::Session(undef, $sid, {Directory=>'/tmp'});

# logout and delete session
if(param('delete') eq "true"){
   $session->clear();
   $session->delete;
   $session->flush();

}


note: i am using expire timeout when creating the session:
         $session = new CGI::Session(undef, $cgi, {Directory=>'/tmp'});                
         $session->save_param($cgi);
         $session->expire(300);
         $sid = $session->id();

please help
thanks.
0
Comment
Question by:weissman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 78

Accepted Solution

by:
arnold earned 500 total points
ID: 39739706
You should make sure you have a cron job that goes through deleting session files from /tmp based on file age to deal with sessions that expired where the user did not logout.
As well as make sure not to run out of space or have the wrong data to .....

You might want to refer to
http://search.cpan.org/~sherzodr/CGI-Session-3.95/Session/Tutorial.pm#DELETING_A_SESSION
0
 

Author Comment

by:weissman
ID: 39739729
thanks you very much...

it is strange that i need to delete these sessions manualy ! i have read the link you send  and implement te session according to it .... it is strange that they do not said anything about
cron job!

if i change the session to database or anything else should i need also the cron job or it will
done automaticly.

thanks a lot
0
 
LVL 78

Assisted Solution

by:arnold
arnold earned 500 total points
ID: 39740262
Yes, you would need to have a clean-up process just in case.
i.e. some users instead of loging out, close the browser.
If it is in a database, you could as part of the function to add entries, issue a delete for all expired records.  In this case though, you have to make sure that you continually adjusting the expiration every time the user accesses the data so not to delete the session.

another option if you are getting a new session ID, issue a delete to the database deleting any record with this session ID, then insert your new one.
i.e.
session=new session comes up as SDFSDOI
you would then issue a
delete from sesssion_table where session_table where sessionID='SDFSDOI'
this will mean though that your session_table would grow and include old sessions until such time that a previously issued session ID resurfaces.
The existence of old expired sessions will mean you will have more rows that you need in the database and that may impact performance as well as consume more of your space for storing this data.
0
 

Author Closing Comment

by:weissman
ID: 39744397
Thanks
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Fine Tune your automatic Updates for Ubuntu / Debian
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question