http://www.freeside.biz/mediawiki/index.php?title=Freeside:4:Documentation:Developer/FS/session&feed=atom&action=historyFreeside:4:Documentation:Developer/FS/session - Revision history2024-03-28T20:18:34ZRevision history for this page on the wikiMediaWiki 1.27.7http://www.freeside.biz/mediawiki/index.php?title=Freeside:4:Documentation:Developer/FS/session&diff=9338&oldid=prevJeremyd: Edit via perl MediaWiki framework (1.13)2015-11-18T15:29:33Z<p>Edit via perl MediaWiki framework (1.13)</p>
<p><b>New page</b></p><div>==NAME==<br />
FS::session - Object methods for session records<br />
<br />
==SYNOPSIS==<br />
<code><br />
use FS::session;<br />
<br />
$record = new FS::session \%hash;<br />
$record = new FS::session {<br />
'portnum' => 1,<br />
'svcnum' => 2,<br />
'login' => $timestamp,<br />
'logout' => $timestamp,<br />
};<br />
<br />
$error = $record->insert;<br />
<br />
$error = $new_record->replace($old_record);<br />
<br />
$error = $record->delete;<br />
<br />
$error = $record->check;<br />
<br />
$error = $record->nas_heartbeat($timestamp);<br />
</code><br />
==DESCRIPTION==<br />
An FS::session object represents an user login session. FS::session inherits from FS::Record. The following fields are currently supported:<br />
<br />
; sessionnum - primary key; portnum - NAS port for this session - see [[Freeside:4:Documentation:Developer/FS/port|FS::port]]; svcnum - User for this session - see [[Freeside:4:Documentation:Developer/FS/svc acct|FS::svc_acct]]; login - timestamp indicating the beginning of this user session.; logout - timestamp indicating the end of this user session. May be null, which indicates a currently open session.<br />
==METHODS==<br />
; new HASHREF<br />
:Creates a new session. To add the session to the database, see [[#insert|"insert"]].<br />
<br />
:Note that this stores the hash reference, not a distinct copy of the hash it points to. You can ask the object for a copy with the ''hash'' method.<br />
; insert<br />
:Adds this record to the database. If there is an error, returns the error, otherwise returns false. If the `login' field is empty, it is replaced with the current time.<br />
; delete<br />
:Delete this record from the database.<br />
; replace OLD_RECORD<br />
:Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false. If the `logout' field is empty, it is replaced with the current time.<br />
; check<br />
:Checks all fields to make sure this is a valid session. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.<br />
; nas_heartbeat<br />
:Heartbeats the nas associated with this session (see [[Freeside:4:Documentation:Developer/FS/nas|FS::nas]]).<br />
; svc_acct<br />
:Returns the svc_acct record associated with this session (see [[Freeside:4:Documentation:Developer/FS/svc acct|FS::svc_acct]]).<br />
<br />
==BUGS==<br />
Maybe you shouldn't be able to insert a session if there's currently an open session on that port. Or maybe the open session on that port should be flagged as problematic? autoclosed? *sigh*<br />
<br />
Hmm, sessions refer to current svc_acct records... probably need to constrain deletions to svc_acct records such that no svc_acct records are deleted which have a session (even if long-closed).<br />
<br />
==SEE ALSO==<br />
[[Freeside:4:Documentation:Developer/FS/Record|FS::Record]], schema.html from the base documentation.</div>Jeremyd