ABSTRACT

WWW::Authen::Simple provides another way to do cookie based sessions and authentication. It's goal is to provide a very simple API to handle sessions and authentication.

The database layout has been abstracted, so you should be able to fit this into whatever database layout you currently use, or use the provided default to base your application.

NOTE: the database abstraction is configured by a hash. If changes to it's structure are needed, you currently have to rebuild the entire hash, and pass it in (ie. there is no API to make it easy to change yet).

Logs the current user out by nulling out their session ticket in the database.

$simple->logged_in();

Returns 1 if the user is logged in. Returns undef is login() was called, but the user failed authentication. Returns 0 (zero) if the login() hasn't been called yet.

$simple->uid();

Get the current session user id.

$simple->username();

Get the current session username.

$simple->groups();

Returns an array of all groups names and group id's the user belongs to.

$simple->in_group($group,$rw);

$group can be the group name, or the group id.

$rw (optional) can be:

1 : Read access for the group.
2 : Write access for the group.
3 : Both read and write access for the group.
r : Read access for the group.
w : Write access for the group.
rw : Both read and write access for the group.

If called without the $rw option, it returns the raw access bits (will be true if the user is in the group and has any level of access: read, write, or both).

If called with the $rw option, returns true if the user is in the group, and has that level of access. Returns false otherwise.

Cleans out the old sessions from the session database. Should be called once in a while from a cron script. The frequency of calls to this is up to you, and it's need depends on how heavy your usage is. If you never call cleanup(), it won't be the end of the world... things will keep working just fine.

$simple->cleanup_seconds($integer_seconds);

How old a session entry should be before it get's cleaned out. Defaults to 43200 seconds (12 hours).

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.