Welcome Guest, Not a member yet? Register   Sign In
Session interference
#1

[eluser]Ñuño Martínez[/eluser]
I'm not sure how to call that.

I had two different applications that use CodeIgniter. I'm sure nobody will use them at same time, but I've discovered that when I start application#1 the application#2's session is removed.

I'm using a helper to check the user login with sessions. The code is this:
Code:
function SessionExists ($Redirect = true)
{
  log_message ('info', 'Checks session...');
  $CI =& get_instance ();
  $CI->load->library ('session');
  if ($CI->session->userdata ('logged_in'))
    if ($CI->session->userdata ('user') !== false &&
    $CI->session->userdata ('key') !== false)
      return true;
  log_message ('info', "Can't find session.");
  if ($Redirect) {
    log_message ('debug','Redirect to '.$CI->config->item('base_url').'login.');
    header ('location: '.$CI->config->item ('base_url').'login');
    die ('<p>Redirecting...</p>');
  }
  return false;
}
I think this code is self-explaining. This just checks if there's a session with the variables, the "user" and "key" will be checked by the application itself.

Is something wrong there?
#2

[eluser]Randy Casburn[/eluser]
Are you certain this is what is killing your session?

I suspect your session is being over-written due to what I call the 'redirect' effect.

As a test of this you might try commenting out the redirect and var_dumping your session data to see what actually is surviving at that moment just prior to the redirect. If it is intact, your redirect is killing your session because the user is not found.

Just a thought,

Randy
#3

[eluser]Ñuño Martínez[/eluser]
The $_SESSION is empty always, even when it logs in correctly. :-S

But I had an idea. May be the problem is that both applications are in the same server with same URI/IP (localhost, in this case) and the query is requested by the same client. :question:
#4

[eluser]Randy Casburn[/eluser]
[quote author="Ñuño Martínez" date="1223392213"]But I had an idea. May be the problem is that both applications are in the same server with same URI/IP (localhost, in this case) and the query is requested by the same client. :question:[/quote]

Do you have the session cookies named the same in both applications? Then the answer is "yes, this is likely the case." Change those names and let's try that.

Randy
#5

[eluser]Ñuño Martínez[/eluser]
[quote author="Randy Casburn" date="1223402970"]Do you have the session cookies named the same in both applications?[/quote] May be: I didn't change the cookies configuration.

Thanks for the advices. Smile
#6

[eluser]Randy Casburn[/eluser]
You are very welcome.

Randy




Theme © iAndrew 2016 - Forum software by © MyBB