Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Session data gone after redirect (CI 2)
#1

[eluser]daBayrus[/eluser]
My system was working just fine using CI 2 Beta. Today, I decided to use the official release. The first thing I noticed was that I can log in but after the login redirection I am prompted that I have logged out. I noticed that when using database to store sessions, the userdata is not being saved on the first session but on another newly created session. I can no longer reference the saved userdata because I am now using another session, making me unable to access the redirected controller because of the restriction I placed that only logged users may access the page. After subsequent browser refreshes, there were too many session entries created on the ci_sessions database.

I tried not using the database and instead used cookies. I used var_dump on the $ci->session->userdata and everything seems fine after logging in and the data was set. After the redirect, the var_dump resulted to an empty session userdata. I don't know what's going on.

Thanks for the help.
#2

[eluser]Kobus M[/eluser]
[quote author="daBayrus" date="1296830519"]My system was working just fine using CI 2 Beta. Today, I decided to use the official release. The first thing I noticed was that I can log in but after the login redirection I am prompted that I have logged out. I noticed that when using database to store sessions, the userdata is not being saved on the first session but on another newly created session. I can no longer reference the saved userdata because I am now using another session, making me unable to access the redirected controller because of the restriction I placed that only logged users may access the page. After subsequent browser refreshes, there were too many session entries created on the ci_sessions database.

I tried not using the database and instead used cookies. I used var_dump on the $ci->session->userdata and everything seems fine after logging in and the data was set. After the redirect, the var_dump resulted to an empty session userdata. I don't know what's going on.

Thanks for the help.[/quote]

I am having the exact same problem, but still on CodeIgniter version 1.7.2. Does anyone have information in this regard? If redirect is not the best way to switch between controllers, what is?

Thanks

Kobus
#3

[eluser]InsiteFX[/eluser]
Please check your web browser cookie settings.

This can sometimes cause problems.

InsiteFX
#4

[eluser]Kobus M[/eluser]
[quote author="InsiteFX" date="1296931603"]Please check your web browser cookie settings.

This can sometimes cause problems.

InsiteFX[/quote]

Cookies is not a problem. The problem occurs in all browsers I have: IE 7, Chrome 5, Safari 5, Opera 10 and FF 3, most of them with default settings which would mean cookies are enabled, right?

Also, using different sites with login mechanisms work - hence further ruling out the cookie problem possibility.

Thanks for the response, InsiteFX.

Kobus
#5

[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.
#6

[eluser]Kobus M[/eluser]
[quote author="arbme666" date="1296935817"]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.[/quote]

I do not redirect to another directory. My config is as follows (as I am still developing):

Code:
$config['cookie_domain']    = '.localhost';
$config['cookie_path']        = '/admax/';

Thanks arbme666.

Regards,

Kobus
#7

[eluser]toopay[/eluser]
leave it as deafult
Code:
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";
#8

[eluser]Unknown[/eluser]
Hi,

I upgraded a working site (1.7.2 to 2.0) late on Friday. I also experienced a session problem. Not sure it's confined to just redirects. As I experienced a "loss of session data" with redirects and posts. Ran out of time trying to debug it but watching the database and packet captures it was starting to look like a new session was being created as if something was wrong with the cookie but again I hadn't proved that yet.

Not sure it's a browser issue as the site in question is actually a VXML application and the "browser" in question was Voxeo.

Something odd happening for sure.

---
Sean

UPDATE: Fixed. Not a CI 2.0 problem. The VXML browser was configured to go to a url with just host name in it. Application was configured with the FQN so on redirects and posts the URL changed and browser did not send back previously set cookies so CI would create a new one each time.
#9

[eluser]Kobus M[/eluser]
[quote author="toopay" date="1296949496"]leave it as deafult
Code:
$config['cookie_domain']    = "";
$config['cookie_path']        = "/";
[/quote]

Thanks to everyone for their help. Nothing solve my problem though, and I ran out of time. I am going to try another framework for now. Maybe later when time is more on my side, will I try CI again.

Kobus
#10

[eluser]toopay[/eluser]
just curious with your unbelievable case, can you uploaded your full packed CI which you use now, and post some url to download here...

By the way, i think session stuff is just a little part of any application development, and its just some easy part.




Theme © iAndrew 2016 - Forum software by © MyBB