Exemplo n.º 1
0
void session_interface::update_exposed(bool force)
{
	for(data_type::iterator p=data_.begin();p!=data_.end();++p) {
		data_type::iterator p2=data_copy_.find(p->first);
		if(p->second.exposed && (force || p2==data_copy_.end() || !p2->second.exposed || p->second.value!=p2->second.value)){
			set_session_cookie(cookie_age(),p->second.value,p->first);
		}
		else if(!p->second.exposed && ((p2!=data_copy_.end() && p2->second.exposed) || force)) {
			set_session_cookie(-1,"",p->first);
		}
	}
	for(data_type::iterator p=data_copy_.begin();p!=data_copy_.end();++p) {
		if(p->second.exposed && data_.find(p->first)==data_.end()) {
			set_session_cookie(-1,"",p->first);
		}
	}
}
Exemplo n.º 2
0
void session_interface::save()
{
	if(storage_.get()==NULL || !loaded_ || saved_)
		return;
	check();
	new_session_  = data_copy_.empty() && !data_.empty();
	if(data_.empty()) {
		if(get_session_cookie()!="")
			storage_->clear(*this);
		update_exposed(true);
		return;
	}

	time_t now = time(NULL);

	bool force_update=false;
	if(data_==data_copy_) {
		if(how_==fixed) {
			return;
		}
		if(how_==renew || how_==browser) {
			int64_t delta=now + timeout_val_ - timeout_in_;
			if(delta < timeout_val_ * 0.1) {// Less then 10% -- no renew need
				return;
			}
		}
		force_update=true;
	}

	string ar;
	save_data(data_,ar);
	
	temp_cookie_.clear();
	storage_->save(*this,ar,session_age(),new_session_,on_server_);
	set_session_cookie(cookie_age(),temp_cookie_);
	temp_cookie_.clear();

	update_exposed(force_update);	
	saved_=true;
}
Exemplo n.º 3
0
void session_interface::save()
{
    if(storage.get()==NULL || saved)
        return;
    check();
    new_session  = data_copy.empty() && !data.empty();
    if(data.empty()) {
        if(get_session_cookie()!="")
            storage->clear(this);
        update_exposed();
        return;
    }

    time_t now = time(NULL);

    if(data==data_copy) {
        if(how==fixed) {
            return;
        }
        if(how==renew || how==browser) {
            int64_t delta=now + timeout_val - timeout_in;
            if(delta < timeout_val * 0.1) {// Less then 10% -- no renew need
                return;
            }
        }
    }

    string ar;
    save_data(data,ar);

    temp_cookie.clear();
    storage->save(this,ar,session_age(),new_session);
    set_session_cookie(cookie_age(),temp_cookie);
    temp_cookie.clear();

    update_exposed();
    saved=true;
}