set_userdata() not work |
[eluser]phparif[/eluser]
I am facing a problem with CI session. I use this code : $sessionData = array( 'userName' => $name, 'email' => $email, 'password' => $password, 'isLogedIn'=> TRUE ); $this->session->set_userdata($sessionData); But when i try to retrieve data it show only this data, My original data not show : var_dump($this->session->all_userdata()); array(4) { ["session_id"]=> string(32) "e61ca2c94c6832577aa9296424718caf" ["ip_address"]=> string(9) "127.0.0.1" ["user_agent"]=> string(90) "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28" ["last_activity"]=> int(1334332439) }
[eluser]Samus[/eluser]
[quote author="phparif" date="1334335958"]I am facing a problem with CI session. I use this code : $sessionData = array( 'userName' => $name, 'email' => $email, 'password' => $password, 'isLogedIn'=> TRUE ); $this->session->set_userdata($sessionData); But when i try to retrieve data it show only this data, My original data not show : var_dump($this->session->all_userdata()); array(4) { ["session_id"]=> string(32) "e61ca2c94c6832577aa9296424718caf" ["ip_address"]=> string(9) "127.0.0.1" ["user_agent"]=> string(90) "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.28) Gecko/20120306 Firefox/3.6.28" ["last_activity"]=> int(1334332439) } [/quote] Would you mind posting the full code?
[eluser]Aken[/eluser]
Make sure that your sessions are being created properly, instead of a new one every time a page loads (a common problem with cookies not being configured properly).
[eluser]Pakm@n[/eluser]
I have the same problem but with chrome and IE i dont understand why, cus i have already an application with a login form. anyways, it was working with chrome and firefox week ago, and now it only works on firefox help please ! this is my controller for login Code: function validate_credentials(){ this is the funtion from the model Code: function validateAdmin(){ if the validation worked, it sends me to a new controller that checks on the constructor iF the session variable is set to true: Code: function is_logged_in(){
[eluser]InsiteFX[/eluser]
None of you have stated what kind of sessions you are using! Regular or Database. 1) IE hates the underscore in the session cookie name! 2) Make sure that the database session table is correct and the newest one! Another thing to keep in mind is that cookies are not updated until a page refresh! So if you try to do anything with a cookie before a page refresh you will not get the results you expect! Which is what Aken is trying to point out to you...
[eluser]Pakm@n[/eluser]
sorry i forgot to place how is my config file Code: $config['sess_cookie_name'] = 'cisession'; i don't know for sure whats wrong cus it was working good with firefox and chrome, i don't care much about IE, but anyways i followed some other posts saying that cookie name shouldn't have underscores. I'm not using a database for my cookies. I don't if this my help, I started building the application in Mexico, and now im in Alaska for 3 months. Thanks for your help.
[eluser]Pakm@n[/eluser]
[quote author="InsiteFX" date="1338117785"]None of you have stated what kind of sessions you are using! Regular or Database. 1) IE hates the underscore in the session cookie name! 2) Make sure that the database session table is correct and the newest one! Another thing to keep in mind is that cookies are not updated until a page refresh! So if you try to do anything with a cookie before a page refresh you will not get the results you expect! Which is what Aken is trying to point out to you... [/quote] One more thing, this application works like this: 1.- The user types username and password 2.- The form is send to the validateCredentials function on the login controller 3.- If username and password are correct, the session vriable is created and then redirects to a user controller 4.- The user controller validates in it's constructor if theres a session variable or that the session variable equals 1. 5.- If the validation worked, the user controller works, otherwise it displays an error message with a link that redirects to the login form
[eluser]InsiteFX[/eluser]
If your changing timezones then you may need to set it in index.php like I do for running on localhost! Code: /** PHP Timezone List Also make sure that your computer clock is set correct!
[eluser]Pakm@n[/eluser]
[quote author="InsiteFX" date="1338142175"]If your changing timezones then you may need to set it in index.php like I do for running on localhost! Code: /** PHP Timezone List Also make sure that your computer clock is set correct! [/quote] Ohh,i see, well, the application is for a client in mexico, he hired the hosting service and i think the server must be in mexico. the application default time zone is set to mexico city, and my computer clock is set to alaska's timezone (UTC -9:00) I'll try changing the time on my computer first and then on the application, after that i'll let u know if that worked thanks so much for your help
[eluser]InsiteFX[/eluser]
If the timezones are not correct the time for sessions and cookies will not match and cause problems! If the server is in Mexico then just set the timezone like I showed you above to Mexico. |
Welcome Guest, Not a member yet? Register Sign In |