Problem:
Working CodeIgniter framework you can face the session problem. the problem is when you storing the values in session and redirect the page. then session destroyed automatically, it is loosing session data even you have properly loaded session library $this->load->library('session') in constructor.see the below code:
public function myset()
{
$this->session->set_userdata('mydata', 'data');
redirect('/', 'refresh');
}
function index()
{
// loosing here data
$mydata = $this->session->userdata('mydata');
}
Solution:
As we are seeing many new frameworks are coming today. but the Mother and base of all frameworks is Core PHP, So we must have good knowledge about Core PHP. Here I have solved this session problem by Core PHP.Example:
session_start();public function myset()
{
$_SESSION['mydata']='data'
redirect('/', 'refresh');
}
function index()
{ $mydata='';
if(isset($_SESSION['mydata']) && !empty($_SESSION['mydata'])) {
$mydata= $_SESSION['mydata']);
}
}
Thanks a lot. It's work! :D
ReplyDeletenot proper solution,
ReplyDeleteDown Vote
this code working is not CI base please make sore propre solution
ReplyDeleteYou can use 100% pure oil for cooking.
ReplyDeleteBuy Shreeja Oil Maker Machine. Shreeja Oil Extraction Machine is able to extract oil from various seeds like peanuts, Coconut, Sesame, Soybean, macadamia nuts, walnuts, sunflower seeds, vegetable seeds flaxseed etc.
Oil Maker Machine