CodeIgniter Forums
Session not working in 1 computer - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Session not working in 1 computer (/showthread.php?tid=68941)

Pages: 1 2


Session not working in 1 computer - coolerkid9090 - 09-15-2017

My sessions work on all computers except 1 computer. It sets the session variable, but when you go back, the data doesn't exist in the session. I tried setting cookies in PHP and those worked fine. I checked all the windows settings for cookies and they are all allowed. I also tried having Codeigniter use a database for sessions and that didn't work either, even though I see the session data stored in the database. It makes no sense. What could possible cause Codeigniter sessions not to work on just that 1 specific computer? Thanks!

This is my test script:



Code:
if (isset($_GET['cookiecheck'])) {

   print_r($this->session->userdata);

} else {

   $cookie_data = array('valid' => true, 'name' => "My Name");

   $cookie_data = array('cookie' => $cookie_data);

   $this->session->set_userdata($cookie_data);

   die(header("Location: http://myurl.com/test?cookiecheck=1"));

}



RE: Session not working in 1 computer - Narf - 09-15-2017

Whatever it is, the problem is in that one PC ... not your code.


RE: Session not working in 1 computer - coolerkid9090 - 09-16-2017

(09-15-2017, 03:29 PM)Narf Wrote: Whatever it is, the problem is in that one PC ... not your code.

But how do I fix it? It's only codeigniter. I can set cookies fine through regular PHP on that computer.


RE: Session not working in 1 computer - Narf - 09-16-2017

I couldn't possibly know how you'd fix it, because I have no idea what the problem is.

What I do know is that if something doesn't work on a single computer, but works everywhere else, then the problem is in that computer. It may happen that you encounter this while using CodeIgniter, but if I had an euro for every time someone said "it doesn't work in codeigniter" and then it turned out that's just a coincidence, I could buy a new car (for real, not joking).


RE: Session not working in 1 computer - skunkbad - 09-16-2017

(09-16-2017, 07:42 AM)coolerkid9090 Wrote:
(09-15-2017, 03:29 PM)Narf Wrote: Whatever it is, the problem is in that one PC ... not your code.

But how do I fix it? It's only codeigniter. I can set cookies fine through regular PHP on that computer.

When dealing with session problems in general, it's good to provide your session configuration, and if you're using database sessions, a copy of your sessions table schema. Also, when you say it doesn't work on one computer, what kind of O/S and browser? "Computer" can mean a lot of things these days.

Like Narf said, if it only doesn't work on one computer, then it's probably the computer, but in the past some people had problems with specific browsers. I think that was a long time ago though, and not sure if that's even a thing anymore.


RE: Session not working in 1 computer - coolerkid9090 - 09-16-2017

(09-16-2017, 01:04 PM)skunkbad Wrote:
(09-16-2017, 07:42 AM)coolerkid9090 Wrote:
(09-15-2017, 03:29 PM)Narf Wrote: Whatever it is, the problem is in that one PC ... not your code.

But how do I fix it? It's only codeigniter. I can set cookies fine through regular PHP on that computer.

When dealing with session problems in general, it's good to provide your session configuration, and if you're using database sessions, a copy of your sessions table schema. Also, when you say it doesn't work on one computer, what kind of O/S and browser? "Computer" can mean a lot of things these days.

Like Narf said, if it only doesn't work on one computer, then it's probably the computer, but in the past some people had problems with specific browsers. I think that was a long time ago though, and not sure if that's even a thing anymore.

It's a Windows 10 PC. I tried IE, Firefox, and Chrome. I tried using Cookies, then database and they both had the same problem. I just don't understand what would cause it to not work on 1 specific computer using Codeigniter, but works fine with straight up PHP cookies. At its core, Codeigniter sets the cookie using PHP.


RE: Session not working in 1 computer - skunkbad - 09-16-2017

(09-16-2017, 03:07 PM)coolerkid9090 Wrote:
(09-16-2017, 01:04 PM)skunkbad Wrote:
(09-16-2017, 07:42 AM)coolerkid9090 Wrote:
(09-15-2017, 03:29 PM)Narf Wrote: Whatever it is, the problem is in that one PC ... not your code.

But how do I fix it? It's only codeigniter. I can set cookies fine through regular PHP on that computer.

When dealing with session problems in general, it's good to provide your session configuration, and if you're using database sessions, a copy of your sessions table schema. Also, when you say it doesn't work on one computer, what kind of O/S and browser? "Computer" can mean a lot of things these days.

Like Narf said, if it only doesn't work on one computer, then it's probably the computer, but in the past some people had problems with specific browsers. I think that was a long time ago though, and not sure if that's even a thing anymore.

It's a Windows 10 PC. I tried IE, Firefox, and Chrome. I tried using Cookies, then database and they both had the same problem. I just don't understand what would cause it to not work on 1 specific computer using Codeigniter, but works fine with straight up PHP cookies. At its core, Codeigniter sets the cookie using PHP.

Maybe it's some antivirus setting or something. Everything else that comes to mind is too offensive to say in this forum ...


RE: Session not working in 1 computer - InsiteFX - 09-17-2017

Windows 10 Cookie Settings:

1) Control Panel
2) Click on Network and Internet
3) Click on Internet Options
4) In the Dialog click on the Privacy tab
5) Click the Advanced button under Settings
6) Set your Cookie Settings
7) Check the Always allow session cookies if it is not checked


RE: Session not working in 1 computer - Narf - 09-17-2017

(09-16-2017, 03:07 PM)coolerkid9090 Wrote: I tried using Cookies, then database and they both had the same problem.

Another piece of info that you should've provided, is that you're using CI2.

CI2 was discontinued 2 years ago!


RE: Session not working in 1 computer - coolerkid9090 - 09-17-2017

(09-17-2017, 06:55 AM)Narf Wrote:
(09-16-2017, 03:07 PM)coolerkid9090 Wrote: I tried using Cookies, then database and they both had the same problem.

Another piece of info that you should've provided, is that you're using CI2.

CI2 was discontinued 2 years ago!

I am using CI3.