Reputation: 1
I have some problems when I try to save my variable in session. I followed all the steps to save in session but it did not work in any way until I tried to see if it was for the htacces but I could never solve it.
$autoload['libraries'] = array('database','session', 'encrypt');
And this is my configuration in the file
config/config.php
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'caja_prymera';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
in the autoload I configured the library and this is my code in the controller.
function solicitar() {
$data['error'] = EXIT_ERROR;
$data['msj'] = null;
try {
$json_service = '{"tipo": "A","Nombre": "juan","cantidad_max": 3000}';
$nombre = __getTextValue('nombre');//validation
$apellido = __getTextValue('apellido');//validation
$dni = _post('dni');
$email = _post('email');
$newdata = array();
$tipo_producto = PRODUCTO_MICASH;
if($dni == null || $dni == '') {
throw new Exception('Ingrese su DNI');
}
if(strlen($dni) != 8) {
throw new Exception('El DNI debe contener 8 caracteres');
}
$json = json_decode($json_service);
$session = array('nombre' => $nombre,
'apellido' => $apellido,
'dni' => $dni,
'email' => $email,
'tipo_solicitud' => $json->tipo,
'cantidad' => $json->cantidad_max,
'tipo_producto' => $tipo_producto
);
$this->session->set_userdata('deliverdata', $session);
if($dni == null) {
throw new Exception('Ingrese su DNI');
}else {
if($json->tipo == 'A') {
if($tipo_producto == PRODUCTO_MICASH) {
$data['url'] = RUTA_CAJA.'c_preaprobacion';
}else {
$data['url'] = RUTA_CAJA.'c_marca';
}
}else if($json->tipo == 'B') {
$data['url'] = RUTA_CAJA.'c_losentimos';
}else if($json->tipo == 'C') {
$data['url'] = RUTA_CAJA.'c_noencontrado';
}
}
$data['error'] = EXIT_SUCCESS;
} catch (Exception $e){
$data['msj'] = $e->getMessage();
}
echo json_encode(array_map('utf8_encode', $data));
}
And this is my code when i get the session in my other controller:
public function index() {
$data['nombreDato']=':D';
$data['nombre'] = _getSesion('nombre');//_getSesion = $this->session->userdata
$nombre = $this->session->userdata('nombre');
_log(print_r($this->session->all_userdata('deliverdata'), true));
$sueldo = $this->sueldo;
$minAuto = null;
$maxAuto = null;
$plazo = null;
$minPrestamo = null;
$maxPrestamo = null;
$valorAuto = null;
$minInicial = null;
$maxInicial = null;
$cantPago = 100000;
$minIniPorc = $this->minIniPorc;
$maxIniPorc = $this->maxIniPorc;
$arr = $this->array_datos;
foreach ($arr as $row) {
$plazo = $row['plazo'];
$minPrestamo = $row['mont_min'];
$maxPrestamo = $row['mont_max'];
$minAuto = $minPrestamo/(1-$minIniPorc);
$maxAuto = $maxPrestamo/(1-$maxIniPorc);
}
$valorAuto = ($minAuto+$maxAuto)/2;
$minInicial = max($valorAuto-$maxPrestamo,$valorAuto*$minIniPorc);
$maxInicial = min($valorAuto-$minPrestamo,$valorAuto*$maxIniPorc);
'mi_cash' == PRODUCTO_MICASH ? $titulo = 'Felicidades!!! Tienes un
préstamo pre aprobado' : $titulo = '';
$data['tipo_product'] = $titulo;
$data['iniRango'] = round($valorAuto/100)*100;
$data['minAuto'] = round($minAuto/100)*100;
$data['maxAuto'] = round($maxAuto/100)*100;
$data['max_cuota'] = round($maxInicial/100)*100;
$data['min_cuota'] = round($minInicial/100)*100;
$data['cantPago'] = round($maxInicial/100)*100;
$data['mensual'] = round($minInicial/100)*100;
$this->load->view('v_preaprobacion', $data);
}
Please help me solve my problem
Upvotes: 0
Views: 48
Reputation: 8964
To use the "files" driver $config['sess_save_path']
must be set to the absolute path where the files are to be written. Documentation HERE.
Permissions to the folder must be set appropriately. Again, consult the documentation.
You might have other problems but I confess to not looking for them. You've got to get session
setup correctly first though.
Upvotes: 1