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

[eluser]smatakajr[/eluser]
Hi All

I am new to CI and im deving a huge project with it.. I was wondering is anybody
could help me figure out why this is happing

I have a login form that does a basic check and then a redirect()

When i load up the browser IE or Firefox

1) I get the login form
2) Authenticates correctly
3) I am redirected to the correct page

Now say i close the browser(s)

1) I get the login form
2) Now say i put a wrong user=>pass combo
3) redirected back to login form
4) Put in correct user/pass
5) redirect BUT

Now the screen prints this

Set-Cookie: ci_session=nXq50v3G8+8RexoYXZN9jBwBTerZny0+snXDsgZUcGOVulueUAdGLByWVOy+QmaNe/agfDKTAT2k1psSXpBmebD5gAJ2TL/sFIv2MntEL4rzNAWqj741E2eTlggwUAiCktw9zyKUvxV6ETcWWIpMxVsT+V

and exits.. any idea why this is driving me nuts..

Thanks
Rick
#2

[eluser]fatdog[/eluser]
Did you ever solved this?
I'm having the exact same issue.
But It's almost impossible for me to debug or fix it, because I can't reproduce the error.

My client (who is at the other side of the Atlantic Ocean) get's this error on her IE7.
I do not get any errors, so I don't really know what to do.

The failure occurs at controller that validates a simple form, then does some set_userdata, then shows a Confirm View. Pretty simple and works nicelly for me, but not for her.

Any clues?

Edit:
I just found out that this same sessions are choking Google Chrome, If I try to set more than 20 variables at the same time, Chrome chokes and throws out this error:
Error 2 (net::ERR_FAILED):Unknown error

I know this is most likely a Chrome bug, but it's a strange coincidence that my client's IE7 chokes on the same script.

How could I go around this issue within CI? (as in not using php native's $_SESSION)
#3

[eluser]tinman[/eluser]
I was also searching an answer about this everywhere but I couldn't find any so I tried to make some debugging of my own. I found out that this problem only occurs when you are using $_SERVER['HTTP_HOST'] is localhost or any domain name without a dot.

To resolve this problem I had to remove domain parameter in setcookie function. Here's my code in system/libraries/Session.php:


setcookie(
$this->sess_cookie,
$cookie_data,
$this->sess_length + time(),
$this->CI->config->item('cookie_path'),
false
);

I've commented the original one line so that when I move the application to the production server it will use the domain name again. You can also perhaps create an if statement line before this to test if the $_SERVER['HTTP_HOST'] has a dot anywhere inside it. If it has then include the domain name. If not then set the value to false.
#4

[eluser]fatdog[/eluser]
Well in my case, the domain name is your typicall domain.com and the weird part was that it only happened in a specific controller. The rest of the site works fine.

While fixing the code to make it work on Chrome (the chrome issue is a bug on their part), it seems to have fixed the other error.

So my guess, is that somehow setting many session variables at once chokes the browsers. I changed the thing to have set one single session array with all the data, and now it works fine.
#5

[eluser]SneakyDave[/eluser]
Quote:I changed the thing to have set one single session array with all the data, and now it works fine.

I'll try that too, because I have a lot of variables that I'm setting for userdata. I'll also look at my apache config to see if there's anything awry in there too.

Thanks for the tips.
#6

[eluser]SneakyDave[/eluser]
Well, I don't know what was going on, I changed things to use a session table in the database, and that seemed to get past the error, but new session_id's were being created with each refresh, but they weren't being stored in the database (just the first one), so I don't know what was going on with that.

So I went back to not using a database, and I changed my set_userdata() function to use an array of values, rather than 20 calls to set_userdata() for each value, and that APPEARS to have fixed it for now.

I also verified I wouldn't have a 4k cookie trying to get set, so that doesn't appears to be the problem either. Maybe I had a corrupted cookie/session, although I tried deleting the cookie from firefox a number of times.




Theme © iAndrew 2016 - Forum software by © MyBB