*	GNU Lesser General Public License along with OpenLSS.
 *	If not, see <http://www.gnu.org/licenses/>.
 */
use LSS\Account\Client;
use LSS\Account\ClientSession;
use LSS\Config;
use LSS\Url;
if (session_id() != '') {
    //check for session
    try {
        if (ClientSession::checkLogin()) {
            //register session
            $token = ClientSession::fetchByToken(ClientSession::getTokenFromSession());
            $session = array_merge(Client::fetch($token['staff_id']), $token);
            ClientSession::storeSession($session);
            unset($session, $token);
            //set tpl globals (if Tpl is available)
            if (is_callable(array('Tpl', '_get'))) {
                Tpl::_get()->set(array('client_name' => ClientSession::get('name'), 'client_lastlogin' => date(Config::get('account.date.general_format'), ClientSession::get('last_login'))));
            }
        } else {
            if (server('REQUEST_URI') != Url::login()) {
                redirect(Url::login());
            }
        }
    } catch (Exception $e) {
        ClientSession::tokenDestroy(ClientSession::getTokenFromSession());
        ClientSession::destroySession();
        redirect(Url::login());
    }
}
Example #2
0
 *
 *	You should have received a copy of the 
 *	GNU Lesser General Public License along with OpenLSS.
 *	If not, see <http://www.gnu.org/licenses/>.
 */
use LSS\Session\Staff;
use LSS\Session\StaffSession;
if (session_id() != '') {
    //check for session
    try {
        if (StaffSession::checkLogin()) {
            //register session
            $token = StaffSession::fetchByToken(StaffSession::getTokenFromSession());
            $session = array_merge(Staff::fetch($token['staff_id']), $token);
            StaffSession::storeSession($session);
            unset($session, $token);
            //set tpl globals (if Tpl is available)
            if (is_callable(array('Tpl', '_get'))) {
                Tpl::_get()->set(array('staff_name' => StaffSession::get('name'), 'staff_lastlogin' => date(Config::get('account.date.general_format'), StaffSession::get('last_login'))));
            }
        } else {
            if (server('REQUEST_URI') != Url::login()) {
                redirect(Url::login());
            }
        }
    } catch (Exception $e) {
        StaffSession::tokenDestroy(StaffSession::getTokenFromSession());
        StaffSession::destroySession();
        redirect(Url::login());
    }
}