Welcome Guest, Not a member yet? Register   Sign In
codeigniter 3.1.9 session failure
#3

(This post was last modified: 10-05-2019, 06:21 AM by ciadmin.)

(10-05-2019, 02:28 AM)Digital_Wolf Wrote:
(10-04-2019, 11:03 PM)chimwemwe Wrote: am building a project and apparently my session works and sometimes stops working.when i post that data to the first controller and access it using a session it works but when i want to access it in other controllers and views it does not.
Since you have not provided additional information in the form of a piece of code where you work with sessions or logs from writable/logs/.
I can assume that you initialized the session class in only one method in which it works for you, and in the one to which you refer to this initialization is not...
You must initialize the library in each controller method for it to work.
If you do not want to do this in each method then it is highly recommended to use models.
/this is my code the one sessions below i need to access across the app

Code:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Requestpage extends CI_Controller {
public function index()
{
parent::__construct();
$this->load->model('requestpage_model');
//getting all services types
$services_list=$this->requestpage_model->get_allservices();
$payments_list=$this->requestpage_model->get_allpaymenttypes();
$data['services_list']=$services_list;
$data['payments_list']=$payments_list;
$data['data'] = ($services_list);
//var_dump($services_list);
$this->load->view('requestpage',$data);
}

public function insert_cont()
{
//insert records into database
$this->load->model('requestpage_model');
$this->load->library('sms');
$this->load->library('email');

//getting the cureent date and time
$currentDateTime = date('Y-m-d H:i:s');
//populating the status of new entry
$new_entry="new pending action";

//we now getting information for the files to be saved
$file_name=$_FILES['id_attachment']['name'];  //file name
$file_type=$_FILES['id_attachment']['type'];  //file type
$file_size=$_FILES['id_attachment']['size'];  //file size
$file_tem_loc=$_FILES['id_attachment']['tmp_name']; //temporary location
$file_store="upload/".$file_name;

move_uploaded_file($file_tem_loc,$file_store);


$new=1;
$data=array(
"salutation"=>$this->input->post('salutation'),
"first_name" => $this->input->post('first_name'),
"last_name" => $this->input->post('last_name'),
"id_type" => $this->input->post('id_type'),
"id_number" => $this->input->post('id_number'),
"address" => $this->input->post('address'),
"contact_number" => $this->input->post('contact_number'),
"other_number" => $this->input->post('other_number'),
"email" => $this->input->post('email'),
"service_id" => $new,
"attachment" => $file_name,
"comment" => $this->input->post('comment')
);


$assigned_by="customer";
$assigned_to="zamtel";
$data1=array(

"assigned_to" => $assigned_to,
"assigned_by" => $assigned_by,
"date_entered" => $currentDateTime,
"date_updated" => $currentDateTime,
"payment_type" => $this->input->post('payment_options'),
"receipt_number" => $this->input->post(''),
"comment" =>$this->input->post('comment')
);


$data2 = $data;
$data3 = $data1;
// $this->load->view('packages',$data2);
session_start();
$_SESSION['customer_data1']=$data2;
$_SESSION['customer_data2']=$data3;


redirect('packages');

}
}

?>

**EDIT: code tags added for readability**
Reply


Messages In This Thread
codeigniter 3.1.9 session failure - by chimwemwe - 10-04-2019, 11:03 PM
RE: codeigniter 3.1.9 session failure - by chimwemwe - 10-05-2019, 05:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB