diff --git a/www/application/config/autoload.php b/www/application/config/autoload.php index 7cdc901..fa5f5ad 100755 --- a/www/application/config/autoload.php +++ b/www/application/config/autoload.php @@ -58,7 +58,7 @@ | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('session'); /* | ------------------------------------------------------------------- diff --git a/www/application/config/config.php b/www/application/config/config.php index 24bf583..ee3d60a 100755 --- a/www/application/config/config.php +++ b/www/application/config/config.php @@ -380,7 +380,7 @@ $config['sess_driver'] = 'files'; $config['sess_cookie_name'] = 'ci_session'; $config['sess_expiration'] = 7200; -$config['sess_save_path'] = NULL; +$config['sess_save_path'] = '/tmp'; $config['sess_match_ip'] = FALSE; $config['sess_time_to_update'] = 300; $config['sess_regenerate_destroy'] = FALSE; @@ -402,7 +402,7 @@ */ $config['cookie_prefix'] = ''; $config['cookie_domain'] = ''; -$config['cookie_path'] = '/'; +$config['cookie_path'] = ''; $config['cookie_secure'] = FALSE; $config['cookie_httponly'] = FALSE; diff --git a/www/application/controllers/Login.php b/www/application/controllers/Login.php index da638ce..bd765d0 100644 --- a/www/application/controllers/Login.php +++ b/www/application/controllers/Login.php @@ -5,10 +5,12 @@ function __Construct(){ parent::__Construct(); $this->load->database(); // load database $this->load->model('User_Info_Model'); // load model + session_start(); $this->output->enable_profiler(TRUE); } public function index(){ + $this->load->helper(array('form', 'url')); $this->load->library('form_validation'); @@ -23,11 +25,14 @@ public function index(){ else { //check if user in db $user = $this->User_Info_Model->isRegistered(); - + $data['user'] = $user; // if yes get user id, launch session, send to home if($user !== []){ - $data['user'] = $user; - redirect('/all_tweets'); + $this->session->set_userdata($user); + $data = $this->session->all_userdata(); + + //$this->load->view('login', $data); + redirect('/User_Tweets'); } // if no, refresh login else $this->load->view('login', $data); diff --git a/www/application/controllers/User_Tweets.php b/www/application/controllers/User_Tweets.php index fc5b71c..6774e60 100644 --- a/www/application/controllers/User_Tweets.php +++ b/www/application/controllers/User_Tweets.php @@ -5,7 +5,6 @@ class User_Tweets extends CI_Controller { function __Construct(){ parent::__Construct(); - //$this->load->library('session'); $this->load->database(); // load database $this->load->model('User_Tweets_Model'); // load model $this->output->enable_profiler(TRUE); diff --git a/www/application/models/User_Info_Model.php b/www/application/models/User_Info_Model.php index e073a8b..b9f6aea 100644 --- a/www/application/models/User_Info_Model.php +++ b/www/application/models/User_Info_Model.php @@ -10,7 +10,7 @@ function isRegistered(){ $this->db->where('username', $username); $this->db->where('password', $password); $query = $this->db->get(); - $result = $query->result_array(); + $result = $query->result_array()[0]; return $result; } // register diff --git a/www/application/models/User_Tweets_Model.php b/www/application/models/User_Tweets_Model.php index 7e066d2..9f62452 100644 --- a/www/application/models/User_Tweets_Model.php +++ b/www/application/models/User_Tweets_Model.php @@ -1,11 +1,13 @@ load->library('session'); + //$this->session->all_userdata(); $this->db->select("first_name, last_name, username, tweet, date_time"); $this->db->from('Users, Tweets'); - $this->db->where("Users.id = Tweets.user_id and Users.id = $user_id"); + $this->db->where("Users.id = Tweets.user_id"); + $this->db->where("Users.id = " . $this->session->userdata('id')); $this->db->order_by('date_time', 'DESC'); $query = $this->db->get(); return $query->result_array(); diff --git a/www/application/views/home.php b/www/application/views/home.php index e2d71ab..85c8318 100644 --- a/www/application/views/home.php +++ b/www/application/views/home.php @@ -11,7 +11,7 @@