Welcome Guest, Not a member yet? Register   Sign In
Session data lost between redirects
#1

[eluser]Kobus M[/eluser]
Hi,

This is driving me insane, and I don't know what is causing the problem.

I have posted a brief note on someone else's post that has a very similar problem, but there is no responses there, and perhaps mine is not 100% the same as his problem.

I am using CodeIgniter 1.7.2 (didn't upgrade yet, not sure I am seeing a need to do so yet, as I am still struggling to learn CI).

I wrote a little controller that handles login functionality for me, that records login attempts, failed attempts, last login information, etc. etc. etc., and after a successful login, I use redirect('controller/method') to change to the appropriate controller once login is successful.

Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in.

Is there a better way to preserve session data than with a redirect? I saw a few post of people using flashdata to do this, but my attempts at that were fruitless.

Could anybody please shed some light on what I am doing wrong, please?

Kobus
#2

[eluser]Kobus M[/eluser]
Before someone jumps on my back for not providing full information. It seems that people are quick to do that here.

CI version: 1.72
Custom libraries: NONE

Sessions config:

Code:
$config['sess_cookie_name']        = 'admaxsession';
$config['sess_expiration']        = 14400;
$config['sess_encrypt_cookie']    = TRUE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'CI_ADMAX_SESSIONS';
$config['sess_match_ip']        = TRUE;
$config['sess_match_useragent']    = FALSE;
$config['sess_time_to_update']     = 14400;

I tried various options. encryption, no encryption. Database, no database, upped the expiration and time to update settings. All possible options in the settings above that I could fathom, and still not working.

I have also followed advice on more than 8 topics with concrete solutions for similar problems here, none solving my problem.

Thanks!

Kobus
#3

[eluser]toopay[/eluser]
[quote author="Kobus M" date="1296914389"]
Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in.[/quote]

How you can identify, that session variables are lost? You dont forgot to load session library, before try to retrieve session data, right?
#4

[eluser]toopay[/eluser]
just simple test, change your config to this :
Code:
$config['sess_expiration']        =0;
#5

[eluser]InsiteFX[/eluser]
If your running Internet Explorer go into Ie Internet options
and check your cookie restrictions!

InsiteFX
#6

[eluser]Kobus M[/eluser]
[quote author="toopay" date="1296924908"][quote author="Kobus M" date="1296914389"]
Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in.[/quote]

How you can identify, that session variables are lost? You dont forgot to load session library, before try to retrieve session data, right?[/quote]

My session library is loaded in my config file by default. To test, I loaded the library even in each controller's index function. Still does not resolve.

How do I know the session variables are being lost? I log sessions in the database, and here is what I see:

1. Every page load, there is a new session ID.
2. Every page load, the user_data fields are blank for that page load's entry.

Is there something else I am missing?

Kobus
#7

[eluser]Kobus M[/eluser]
[quote author="toopay" date="1296924908"][quote author="Kobus M" date="1296914389"]
Upon redirect, the session variables are lost, and therefore the user is not recorded as logged in.[/quote]

How you can identify, that session variables are lost? You dont forgot to load session library, before try to retrieve session data, right?[/quote]

Thanks for the response! I tried what you said, no success.

Kobus
#8

[eluser]Kobus M[/eluser]
[quote author="toopay" date="1296925336"]just simple test, change your config to this :
Code:
$config['sess_expiration']        =0;
[/quote]

Thanks for the response. It does not make any difference.

Have a great day!

Kobus
#9

[eluser]arbme666[/eluser]
Just an idea... do you redirect to another directory?

If so the probem may lie in you cookie settings in config.php. You may have the cookie locked to a certain directory so when you redirect to a different one the cookie is not sent thus having no session data.

config.php
Code:
$config['cookie_domain']    = '.example.com';
$config['cookie_path']        = '/';

Make sure you have a trailing forward slash for cookie path and a fullstop in front of the domain.




Theme © iAndrew 2016 - Forum software by © MyBB