Welcome Guest, Not a member yet? Register   Sign In
What happens with sessions??
#1

[eluser]IEDani[/eluser]
Hi,
I need to use sessions in my app and I am having problems.

First of all I try to use the session library but if you use it the library generate a lot of warnings. The only way to modify it is program in the library, and it can give more troubles.

Can I disable the session system of codeIgniter? how?

So, I decided use the traditional sessions ($_SESSION['var']) but my app don´t reconize it and tell me that $_SESSION is an undefined var.

Can I use the traditional sessions? how?

Thanks you so much!
Dani
#2

[eluser]darkhouse[/eluser]
What warnings do you get? I use the standard session library and store the session data in the database. I don't get any warnings.
#3

[eluser]Skuja[/eluser]
I believe those where headers already sent warnings.
my 2 cents.
#4

[eluser]IEDani[/eluser]
Exactly Skuja, this is the warning (the headers already sent). How can I solve it??
Or how can use the traditional sessions?
Thanks,Dani
#5

[eluser]Dam1an[/eluser]
Unless I'm confusing mysdelf with something else, you can't write to $_SESSION after you've outputted to the browser... this may be intentionally calling a view, or having some whitespace somewhere (eg a new line outside of <?php and ?> tags)
#6

[eluser]Skuja[/eluser]
It is not exactly CI sessions fault. Somewhere, somehow in your app you have some ouput before document headers are sent. There could be a bunch of kinds of things to cause this, starting from invalid document encoding to some extra whitespaceses before <?php tags. Please copy your error messages here and i am sure we wil be able to help you more to find exact reason that causes yours.
#7

[eluser]IEDani[/eluser]
Hi,
I am searching the error but I don´t find it...

----------------
This is the error:
A PHP Error was encountered
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/x.com/httpsdocs/CodeIgniter/system/application/models/acceso_model.php:23)

Filename: libraries/Session.php

Line Number: 662

----------------
This is the code of acceso_model.php, the document that sent the headers (¿?):

<?php
class Acceso_Model extends Model {

function Acceso_Model(){
// Call the Model constructor
parent::Model();
}

function esValido($usuario,$contrasenia){
//compruebo que el usuario existe
$sql='SELECT * FROM Usuarios WHERE usuario=?';
$query = $this->db->query($sql,array($usuario));
$acceso=($query->num_rows() > 0);
//si el usuario existe compruebo que su clave es correcta
if ($acceso){
$row = $query->row();
$acceso= $row->contrasenia == md5($contrasenia);
}
return $acceso;
}
}
?>


----------------
This is a piece of the code of acceso.php, that fix the session and call to acceso_model.php
.......
$this->load->model("Acceso_Model");
if ($this->Acceso_Model->esValido($usuario,$contrasenia)){
$this->load->library('session');
$datosAcceso = array(
'usuario' => $usuario,
'logado' => TRUE
);
$this->session->set_userdata($datosAcceso);
............
--------------------------
I am sure that we can solve it!
Thaks you so much!
Dani
#8

[eluser]TheFuzzy0ne[/eluser]
You probably have a space after the closing ?> tag. It's recommended you actually remove the last ?> tag for this reason. If you look at the core CodeIgniter files, you'll see that all of those files have the closing ?> tag omitted.
#9

[eluser]IEDani[/eluser]
Exactly!! Thanks you so much, it ´s great have your help!
Dani




Theme © iAndrew 2016 - Forum software by © MyBB