File: expire.pl

package info (click to toggle)
libdata-session-perl 1.18-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 476 kB
  • sloc: perl: 2,916; makefile: 7
file content (58 lines) | stat: -rw-r--r-- 1,229 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env perl

use lib 't';
use strict;
use warnings;

use Data::Session;

use DBI;

use File::Spec;
use File::Temp;

use Test;

# -----------------------------------------------

# The EXLOCK is for BSD-based systems.

my($directory)   = File::Temp::newdir('temp.XXXX', CLEANUP => 1, EXLOCK => 0, TMPDIR => 1);
my($data_source) = 'dbi:SQLite:dbname=' . File::Spec -> catdir($directory, 'sessions.sqlite');
my($type)        = 'driver:SQLite;id:MD5;serialize:DataDumper';
my($tester)      = Test -> new
	(
	 directory => $directory,
	 dsn       => $data_source,
	 dsn_attr  => {PrintError => 0}, # Stop msg when trying to delete non-existant table.
	 password  => '',
	 type      => $type,
	 username  => '',
	 verbose   => 1,
	);

$tester -> setup_table(128);

my($session) = Data::Session -> new
(
	dbh     => $tester -> dbh,
	type    => $type,
	verbose => 0, # Affects parse_options().
) || die $Data::Session::errstr;

my($sub) = sub
{
	my($id) = @_;
	my($s)  = Data::Session -> new
	(
		dbh     => $tester -> dbh,
		id      => $id,
		type    => $type,
		verbose => 1, # Affects check_expiry() & parse_options().
	) || die $Data::Session::errstr;

	$s -> expire(-1);
	$s -> check_expiry;
};

$session -> traverse($sub);