Welcome Guest, Not a member yet? Register   Sign In
session data issues
#1

[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() {
  if ($this->session->userdata('is_logged_in')) {
   $this->load->view('members');
  } else {
   redirect('main/restricted');
  }
}

public function restricted() {
  $this->load->view('restricted');
}

public function login_validation() {
  $this->load->library('form_validation');
  
  $this->form_validation->set_rules('email', 'Email', 'required|trim|xss_clean|callback_validate_credentials');
  $this->form_validation->set_rules('password', 'Password', 'required|md5|trim');
  
  if ($this->form_validation->run()){
   $data = array(
    'email' => $this->input->post('email'),
    'is_logged_in' => 1
   );
  
   $this->session->set_userdata($data);
   redirect('main/members');
  } else {
   $this->load->view('login');
  }

}


from my members page
Code:
<!DOCTYPE html>
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="utf-8"&gt;
&lt;title&gt;Members Page&lt;/title&gt;

&lt;/head&gt;
&lt;body&gt;

<div id="container">
<h1>Members Page</h1>

&lt;?php

echo "<pre>";
print_r($this->session->all_userdata());
echo "</pre>";

?&gt;

</div>

&lt;/body&gt;
&lt;/html&gt;




As always any help is appreciated (im sure its something obvious but bare with me I 'm a noob. ) Thanks in advance


Messages In This Thread
session data issues - by El Forum - 11-14-2012, 02:11 PM
session data issues - by El Forum - 11-14-2012, 03:17 PM
session data issues - by El Forum - 11-15-2012, 03:00 PM
session data issues - by El Forum - 11-15-2012, 03:25 PM
session data issues - by El Forum - 11-15-2012, 03:53 PM
session data issues - by El Forum - 11-15-2012, 06:44 PM



Theme © iAndrew 2016 - Forum software by © MyBB