CodeIgniter Forums
Codeigniter deletes the session I wrote after refreshing the page - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Codeigniter deletes the session I wrote after refreshing the page (/showthread.php?tid=79599)



Codeigniter deletes the session I wrote after refreshing the page - huseyinalperenn - 07-06-2021

I am using Codeigniter. I have not encountered such an error in a long time. In my login function inside my login controller, I want to print an array returning from the Login Model to the session. I also use Elephant.io. 

Code:
$this->session->set_userdata($validate); $client->emit('form_data', ['success' => $this->session->all_userdata()]);

when I write the array named $validate to the session, it sends all the data of the session to nodejs with emit at the bottom and there I'm printing to the console.

So when I send $this->session->all_userdata() with emit I can see the data in the $validate array. For your information, the issue has nothing to do with NodeJS. However, when I refresh the page, all the data I have written in the session is deleted. As a solution, I tried 

Code:
$this->session->set_userdata('uid', $validate)

Code:
$_SESSION['uid'] = $validate

 and it didn't work. I've read articles on various sites about this topic on the internet or looked at the same problems and solutions on stackoverflow and similar platforms, but there was no solution to my problem. In the same controller in the construct function.

Code:
$this->session->set_userdata('uid', 'test'); print_r($this->session->all_userdata()); die();

When I print this the 'test' data is not deleted even if I refresh the page hundreds of times. So it works inside the construct. I am calling session library in Construct.

I haven't been able to solve this problem for 2 days now, I've reached the stage of going crazy. I have explained my problem at length here, I hope a solution is found. I am using the latest version of Codeigniter. My PHP version is 7.3.11 I am using Ampps as apache server. Thanks to everyone who has helped so far <3


RE: Codeigniter deletes the session I wrote after refreshing the page - salampard - 07-06-2021

i'm sorry for using ur threads as a way to ask question coz i don't knos how to make one..
if i may to ask u, i come to opposite problems as your, my flashdata session still showing up after i refresh the page, i'm using library session on ci 3 thx


RE: Codeigniter deletes the session I wrote after refreshing the page - InsiteFX - 07-07-2021

If you want users to help you fix your problem then quit using copy and paste it makes it to hard to read your post.


RE: Codeigniter deletes the session I wrote after refreshing the page - paliz - 07-07-2021

Some times session gone

I m not sure why but when store hash code csrf in session some times its gone


RE: Codeigniter deletes the session I wrote after refreshing the page - includebeer - 07-08-2021

(07-06-2021, 06:13 PM)salampard Wrote: i'm sorry for using ur threads as a way to ask question coz i don't knos how to make one..
if i may to ask u, i come to opposite problems as your, my flashdata session still showing up after i refresh the page, i'm using library session on ci 3 thx
Please start your own thread for your question. Go in the right category then click on New Topic at top right of the page.


RE: Codeigniter deletes the session I wrote after refreshing the page - huseyinalperenn - 07-15-2021

(07-06-2021, 12:00 PM)huseyinalperenn Wrote: I am using Codeigniter. I have not encountered such an error in a long time. In my login function inside my login controller, I want to print an array returning from the Login Model to the session. I also use Elephant.io. 

Code:
$this->session->set_userdata($validate); $client->emit('form_data', ['success' => $this->session->all_userdata()]);

when I write the array named $validate to the session, it sends all the data of the session to nodejs with emit at the bottom and there I'm printing to the console.

So when I send $this->session->all_userdata() with emit I can see the data in the $validate array. For your information, the issue has nothing to do with NodeJS. However, when I refresh the page, all the data I have written in the session is deleted. As a solution, I tried 

Code:
$this->session->set_userdata('uid', $validate)

Code:
$_SESSION['uid'] = $validate

 and it didn't work. I've read articles on various sites about this topic on the internet or looked at the same problems and solutions on stackoverflow and similar platforms, but there was no solution to my problem. In the same controller in the construct function.

Code:
$this->session->set_userdata('uid', 'test'); print_r($this->session->all_userdata()); die();

When I print this the 'test' data is not deleted even if I refresh the page hundreds of times. So it works inside the construct. I am calling session library in Construct.

I haven't been able to solve this problem for 2 days now, I've reached the stage of going crazy. I have explained my problem at length here, I hope a solution is found. I am using the latest version of Codeigniter. My PHP version is 7.3.11 I am using Ampps as apache server. Thanks to everyone who has helped so far <3
Notification: A session is being written to the ci_sessions folder. But the session is still not working.


RE: Codeigniter deletes the session I wrote after refreshing the page - InsiteFX - 07-16-2021

Did you try to autoload the session library in application/config/autoload.php

You may also need to make the $validate a static variable to retain its parameters.


RE: Codeigniter deletes the session I wrote after refreshing the page - huseyinalperenn - 07-16-2021

(07-16-2021, 03:14 AM)InsiteFX Wrote: Did you try to autoload the session library in application/config/autoload.php

You may also need to make the $validate a static variable to retain its parameters.

Yes. I call the library on autoload.