Page 1 of 1

timing out a session

Posted: Tue Jun 06, 2006 3:37 pm
by Luke
This function will time out exactly 2 hours after the page is first called I believe. How would I fix this to make it reset the two hours every time the page loads? (my brain is kinda on vacation right now)

Code: Select all

function set_time_out(){
		// Set time start
                $this->duration = 60*60 * 2;
		$this->time_start = $this->get_var('time_start');
		if(!empty($this->time_start)){
			$this->time_out = ($this->time_start + $this->duration);
			if(time() > $this->time_out) $this->destroy();
		}
		else{
			$this->time_start = time();
			$this->set_var('time_start', $this->time_start);
		}
	}

Posted: Tue Jun 06, 2006 3:51 pm
by feyd

Re: timing out a session

Posted: Tue Jun 06, 2006 4:01 pm
by Luke

Code: Select all

function set_time_out(){
		// Set time start
                $this->duration = 60*60 * 2;
		$this->time_start = $this->get_var('time_start');
		if(!empty($this->time_start)){
			$this->time_out = ($this->time_start + $this->duration);
			if(time() > $this->time_out) $this->destroy();
		}
		else{
			$this->time_start = time();
			$this->set_var('time_start', $this->time_start);
		}
		$this->set_var('time_start', time()); // <-- I just needed to add this line I figured it out thanks!
	}