Jump to content


Photo

(SOLVED) Session Prematurly Aborts


  • Please log in to reply
No replies to this topic

#1 bholbrook

bholbrook
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 04 August 2006 - 05:58 PM

**** SOLUTION ****

I had another class extend this class and if i didnt call the construct the first time I saved information it overwrote the session instead of adding to it.

**** SOLUTION ****

I have a class that manages session data (basically, it creates an array and passes one session variable with the array of information). AT any rate, my login script writes to this session successfully, and i ca go through the site no problem, until I upload a file.

I upload a file for parsing (which works and writes the data to the session) but somewhere between retrieving the session and using the data it disappears. I dont believe it is in the class that manages the data (listed below) as it works everywhere else. I've posted it anyways just so you can see.

Is there any type of error that will drop a session?

function __construct($strBaseDir = false){
		
		//recall old info
		$this->data = $this->recallInfoTransfer();
		
		//preset variables
		$this->save("ip",$_SERVER['REMOTE_ADDR']);
		$this->save("admin_ip","24.71.48.237");
		$this->strBaseDir = $strBaseDir;
	
	}
	public function save($key, $value){
	
		$this->data[$key] = $value;
		$this->prepInfoTransfer();
	
	}
	public function read($key){
		
		$this->data = $this->recallInfoTransfer();
		if(is_array($this->data)){
			if(array_key_exists($key, $this->data)){
				return $this->data[$key];
			}
		}
		return false;
	
	}
	public function removeKey($key){
		
		//remove key form local copy
		if(is_array($this->data)) if(array_key_exists($key, $this->data)) unset($this->data[$key]);
		
		//remove key from session copy
		if(is_array($_SESSION['infoTransfer'])) if(array_key_exists($key, $_SESSION['infoTransfer'])) unset($_SESSION['infoTransfer'][$key]);
			
	}
	public function stack($strVariableName, $intArrayKey = NULL, $ArrayValue = false){
		
		if( !isset( $this->$strVariableName )){
		
			$arrVariable = array();
		
		} else {
		
			$arrVariable = $this->$strVariableName;
		
		}
	
		$arrVariable[ $intArrayKey ] = $ArrayValue;
		$this->$strVariableName = $arrVariable;
		return true;
	
	}
	public function save_stack( $strVariableName ){
	
		$this->save( $strVariableName, $this->read_stack( $strVariableName ));
		return true;
	
	}
	public function read_stack( $strVariableName ){
	
		if( isset( $this->$strVariableName )){
		
			return $this->$strVariableName;
		
		} else {
		
			return false;
		
		}
	
	}
	public function prepInfoTransfer(){
	
		if(is_array($this->data)){
			
			$_SESSION['infoTransfer'] = $this->data;
			
		}
	
	}
	public function recallInfoTransfer(){
	
		if(isset($_SESSION) and array_key_exists("infoTransfer",$_SESSION)){
		
			return $_SESSION['infoTransfer'];
		
		}
		
		return array();
	
	}
	function __destruct(){
	
		$this->prepInfoTransfer();
	
	}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users