]> git.decadent.org.uk Git - maypole.git/blob - lib/Maypole/Session.pm
309ff38e601e8fd9bac1959ea399fa63f5dfde82
[maypole.git] / lib / Maypole / Session.pm
1 package Maypole::Session;
2
3 =head1 NAME
4
5 Maypole::Session - Session related functionality for maypole
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 Currently it provides only the generate_unique_id() function, by checking the id's generated by this function and included in submitted forms, it is possible to see if a form has been submitted before.. implementing these checks is left to the developer of that application.
18
19 Further functionality is to be added here in later versions to provide easy access to sessions, either through plugins or builtin methods.
20
21 =head1 FUNCTIONS
22
23 =head2 generate_unique_id()
24
25 my $uid = Maypole::Session::generate_unique_id()
26
27 generates a unique id and returns it, requires no arguments but accepts size, default is 32.
28
29 =cut
30
31 use strict;
32 use Digest::MD5;
33 our $VERSION = 0.01;
34
35 sub generate_unique_id {
36     my $length = shift || 32;
37     my $id = substr(Digest::MD5::md5_hex(Digest::MD5::md5_hex(time(). {}. rand(). $$)), 0, $length);
38     return;
39 }
40
41
42 ###################################################################################################
43 ###################################################################################################
44
45 =head1 TODO
46
47 Currently implementing uniqueness tests of form submissions is left to the Maypole user, we plan to provide an optional default behaviour to automate this if required.
48
49 =head1 SEE ALSO
50
51 L<Maypole>
52
53 =head1 MAINTAINER
54
55 Aaron Trevena, c<teejay@droogs.org>
56
57 =head1 AUTHOR
58
59 Simon Cozens, C<simon@cpan.org>
60
61 =head1 LICENSE
62
63 You may distribute this code under the same terms as Perl itself.
64
65 =cut
66
67
68 1;