]> git.decadent.org.uk Git - maypole.git/blob - lib/Maypole/Session.pm
possible 2.10 release
[maypole.git] / lib / Maypole / Session.pm
1 package Maypole::Session;
2
3 =head1 NAME
4
5 Maypole::Constants - Maypole predefined constants
6
7 =head1 SYNOPSIS
8
9 use Maypole::Session;
10
11 my $uid = Maypole::Session::generate_unique_id()
12
13 =head1 DESCRIPTION
14
15 This class provides session related methods for Maypole such as unique id's for requests.
16
17 =head1 METHODS
18
19 =head2 generate_unique_id()
20
21 my $uid = Maypole::Session::generate_unique_id()
22
23 generates a unique id and returns it, requires no arguments but accepts size, default is 32.
24
25 =cut
26
27 use strict;
28 use Digest::MD5;
29
30 sub generate_unique_id {
31     my $length = shift || 32;
32     my $id = substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, $length);
33     return;
34 }
35
36
37 ###################################################################################################
38 ###################################################################################################
39
40
41 =head1 SEE ALSO
42
43 L<Maypole>
44
45 =head1 MAINTAINER
46
47 Aaron Trevena, c<teejay@droogs.org>
48
49 =head1 AUTHOR
50
51 Simon Cozens, C<simon@cpan.org>
52
53 =head1 LICENSE
54
55 You may distribute this code under the same terms as Perl itself.
56
57 =cut
58
59
60 1;