session data issues |
[eluser]john.weland[/eluser]
I pulled this from my post over at phpacademy and poseted it here as well as I seemingly am getting no hits over there. So I am following along with the phpacademy - codeigniter video tutorials for creating a user registration & login. I am currently on video 7 which deals with session data. here is the link to the video => http://www.youtube.com/watch?v=wpUqyTRxb...0E6A01B1E0 All was going well until I set the session data to display in the members page, at that point my data displayed just as it does in the video minus the email and is_logged_in. in the video it shows as Array( [session_id] => --------------------- [ip_address]=> ------------------ [user_agent]=> --------------------- [last_activity] => ------------------- [user_data] => [email] => ------------------------- [is_logged_in] => 1 ) mine has shown as Array( [session_id] => --------------------- [ip_address]=> ------------------ [user_agent]=> --------------------- [last_activity] => ------------------- [user_data] => ) right then I knew something fishy was going on but I continued anyway with the video doing the restricted.php so now I login (with valid credentials) but still receive the redirect to the restricted page. I can only assume this is because my in my session data my [is_logged_in] is not => 1 I have gone over my code a hundred times and from what I see it matches up with the video tutorial but something obviously is incorrect. from my main controller Code: public function members() { from my members page Code: <!DOCTYPE html> As always any help is appreciated (im sure its something obvious but bare with me I 'm a noob. ) Thanks in advance
[eluser]adamck[/eluser]
In my Login Script.. i set the following user data. Login Controller Function Code: $data = array( Then in the other controllers i have this Code: function index() If you want an entire controller to only work for logged in users you can put the $is_logged_in function at the bottom and then the the $this->is_logged_in(); can go in the page construct Code: function __construct() hope it helps
[eluser]john.weland[/eluser]
Well I couldn't figure it out so I again scrapped the project and started over. I got all the way back to this section about session data sending it and displaying it. It showed the same as before where is should show Array ( [session_id] => e34d75caa00ad6c34890c6ac118904ff [ip_address] => browsing clients IP address [user_agent] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.96 Safari/537.4 [last_activity] => 1352976703 [user_data] => [email] => [email protected] [is_logged_in] => 1 ) it instead shows Array ( [session_id] => e34d75caa00ad6c34890c6ac118904ff [ip_address] => 192.168.6.1 [user_agent] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.96 Safari/537.4 [last_activity] => 1352976703 [user_data] => ) I am on a crazy network here at home my main router is 192.168.1.1 connected to that wirelessly is a router 192.168.2.1 the server is on my PC as a virtual machine running a hypervisor running a virtual server. I noticed rather than showing [ip_address] => 192.168.2.120 (the system I am accessing from ) ts shows the [ip_address] =>192.168.6.1 this ip address is the default gateway of my virtual host running the virtual server. unfortunately I haven't a clue how to fix this issue.
[eluser]skunkbad[/eluser]
What browser are you using, and what are your session/cookie related config settings? Also, a large percentage of session related issues that I see here in the forum involve setting session data immediately before a redirect. I don't know if that's your problem, but it's an observation.
[eluser]john.weland[/eluser]
I tested my hypothisis out on one ofmy old junker PCs here and I was right something about my virtual server being on a different network has made the session show from the default gateway rather than my actual IP when I set this up on my junker on the non-virtual is ran through fine and even gave the correct IP My browser is Chrome cookie/session settings. I am not sure, whatever codeigniter has set as default.
[eluser]john.weland[/eluser]
update. I got my linux server on the same routing at my main machine and my windows server.... using the same files copied from one box to the next. windows box works flawlessly, linux box still doesn't show the session data its like its not carrying the data ... |
Welcome Guest, Not a member yet? Register Sign In |