winix/core/session.cpp

78 lines
1.0 KiB
C++
Executable File

/*
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2012, Tomasz Sowa
* All rights reserved.
*
*/
#include "session.h"
#include "misc.h"
Session::Session()
{
SetTimeToNow();
Clear();
plugin_data.SetSession(this);
}
Session::Session(const Session & ses)
{
operator=(ses);
}
Session & Session::operator=(const Session & ses)
{
/*
we can only copy ses.id because it is needen in SessionContainer
it have indexes to id
*/
Clear();
id = ses.id;
plugin_data.SetSession(this);
return *this;
}
void Session::SetTimeToNow()
{
time = std::time(0);
tm_time = Time(time);
last_time = time;
tm_last_time = tm_time;
// the first request can be a POST (it doesn't matter)
last_time_get = time;
}
// this doesn't clear times
void Session::Clear(bool clear_plugin_data)
{
id = 0;
puser = 0;
rebus_item = 0;
rebus_checked = false;
remember_me = false;
new_session = true;
spam_score = 0;
remove_me = false;
if( clear_plugin_data )
plugin_data.Resize(0);
}