NAME
E2::Session - Load session information about the current E2 user
SYNOPSIS
use E2::Session;
my $session = new E2::Session;
$session->login( "username", "password" ); # See E2::Interface
$session->update;
print "Username: " . $session->this_username; # See E2::Interface
print "\nuser_id: " . $session->this_user_id; # See E2::Interface
print "\nVotes left today: " . $session->votes;
print "\nCools left today: " . $session->cools;
print "\nExperience: " . $session->experience;
print "\nWriteups: " . $session->writeups;
print "\nBorged: " . ($session->borged ? "Yes" : "No");
print "\nForbidden to post: " . ($session->forbidden ? "Yes" : "No");
print "\nServer time: " . $session->time;
if( $session->xpchange ) {
print "\nChange in XP: " . $session->xpchange;
print "\nTo reach level " . $session->nextlevel->{level};
print "\n XP:" . $session->nextlevel->{experience};
print "\n Writeups:" . $session->nextlevel->{writeups};
}
foreach( $session->list_personal_nodes ) {
print "\nPersonal node: $_->{title}";
}
DESCRIPTION
This module allows a user to load his session information This module provides an interface to everything2.com's search interface. It inherits E2::Ticker.
CONSTRUCTOR
- new
-
new
creates anE2::Session
object.
METHODS
- $session->clear
-
This method clears all stored session values.
- $session->update
-
This method fetches the personal session from e2 and makes available all of the access methods below. If a user is not logged in, the only session information fetched will be the servertime (retrievable via
time
) and this user's username and user_id (retrievable viathis_username
andthis_user_id
, which are inherited from E2::Interface).xpchange
andnextlevel
are only available if the user's writeup count or experience number has changed since the user's session was last loaded.update
works very much like the epicenter nodelet on E2, and "last loaded" refers to either updating the session or loading a web page that contains the epicenter.One other side-effect of calling update (or loading the epicenter) is that a user who's been borged must do so at least once, after the length of his borging has expired, before he will be able to speak again.
- $session->votes
- $session->cools
- $session->experience
- $session->writeups
- $session->time
-
These methods return the user's number of votes left today, number of cools left today, their current experience number, their current number of writeups, and the current server time. Example server time: "Sun Mar 16 15:58:20 2003".
- $session->borged
- $session->forbidden
-
These methods return values corresponding, respectively, to whether the current user has been borged and whether the current user has been forbidden to post writeups. Both return boolean values, but
forbidden
, if true, is a text string describing the lock. - $session->xpchange
-
This method returns the user's change in experience since that previous time he updated his user session (or loaded an epicenter nodelet). It is only defined if either the user's experience number or writeup count has changed since the previous update.
- $session->nextlevel
-
This method returns information about requirements the user must meet to reach the next level. It is only defined if either the user's experience number or writeup count has changed since the previous update (either by a call to
update
or by loading the epicenter nodelet).This method returns a hashref with the following keys:
experience # Extra experience required to reach the next level writeups # Extra writeups required to reach the next level level # The next level as an integer
SEE ALSO
E2::Interface, E2::Ticker, http://everything2.com/?node=clientdev http://everything2.com/?node=e2interface
AUTHOR
Jose M. Weeks <jose@joseweeks.com> (Simpleton on E2)
COPYRIGHT
This software is public domain.