NAME

Captive::Portal::Role::Session - Session methods for Captive::Portal

DESCRIPTION

IP addresses of clients must be unique. They are determined by the HTTP-Parameter REMOTE_ADDR. The corresponding MAC-address is determined from the ARP-table. If there are duplicate IP-addresses for different MAC-addresses something bad is happening (ARP-spoofing, ...). Captive::Portal warns on duplicate IP-addresses.

ROLES

All roles throw exceptions on error.

$capo->get_current_session()

Returns the current- or a new session-hash for this HTTP-Client.

$capo->open_sessions_dir()

Open/create the sessions directory defined in the config file.

$capo->clear_sessions_from_disk()

Unlink all session files from disk.

$capo->list_sessions_from_disk()

Return a list of all session filenames in sessions dir.

$capo->get_session_lock_handle(%named_params)

Wrapper for get_lock_handle().

Return a filehandle to the clients session file with the requested lock assigned. There is no unlock required, after destroying the filehandle the file is closed and the lock released.

Named parameters:

key      => ip address of session
shared   => shared lock, defaults to exclusive lock
blocking => blocking lock request, defaults to blocking
try      => number of retries in nonblocking mode, defaults to 1 retry
timeout  => timeout in blocking mode, defaults to 1s
$capo->read_session_handle($lock_handle)

Read the session file for $lock_handle and decode the JSON format into a hashref.

$capo->write_session_handle($lock_handle, $session)

Encode the session hashref into JSON and write the session file belonging to $lock_handle.

$capo->delete_session_from_disk($key)

Unlink session file from disk.

$capo->mk_cookie()

Generate a CaPo cookie with random- and session-data or use the already existing session cookie. The cookie is used to fast reactivate an idle session if the IP/MAC/COOKIE is still matching. Cookies are not mandatory, they are just for a better user experience.

$capo->match_cookie()

Check if request cookie is equal session cookie. Returns true on success and false on failure.

AUTHOR

Karl Gaissmaier, <gaissmai at cpan.org>

LICENSE AND COPYRIGHT

Copyright 2010-2011 Karl Gaissmaier, all rights reserved.

This distribution is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version, or

b) the Artistic License version 2.0.

The full text of the license can be found in the LICENSE file included with this distribution.