Solved

delete session in perl

Posted on 2013-12-24
4
672 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
  • 2
  • 2
4 Comments
 
LVL 76

Accepted Solution

by:
arnold earned 500 total points
Comment Utility
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
Comment Utility
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 76

Assisted Solution

by:arnold
arnold earned 500 total points
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now