Jump to content

Archived

This topic is now archived and is closed to further replies.

bholbrook

(SOLVED) Session Prematurly Aborts

Recommended Posts

**** 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?

[code]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();

}[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.