Welcome Guest, Not a member yet? Register   Sign In
Codeigniter deletes the session I wrote after refreshing the page
#1

(This post was last modified: 07-07-2021, 06:05 AM by huseyinalperenn.)

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
Reply
#2

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
Reply
#3

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

Some times session gone

I m not sure why but when store hash code csrf in session some times its gone
Enlightenment  Is  Freedom
Reply
#5

(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.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#6

(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.
Reply
#7

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#8

(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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB