Welcome Guest, Not a member yet? Register   Sign In
Lost session
#31

Just to throw in a few more random variables into the mix...

I'm on PHP 7.3 & CI 4.0.0-rc.3 (and experienced a similar problem on CI 4.0.0-rc2 too)- whereby, if the user mistypes the address and the rerouting doesn't work out where to send the request, CI automatically redirects to the 404 error page... and every bit of session data seems to disappear.

I've not spent a lot of time trying to work out what's happening, though sessions have been working without a problem (without me having had to fiddle with any of the settings (so everything is as it came/default/out the box))...

Here's another bit of useless chaff, that will probably only muddy the water... if I remember correctly, I believe I previously experienced the same problem of losing session data when using the redirect() command in my code... but manage to side-step the issue at the time by using other ways to call the new page (without using the redirect() command directly).

Undecided
Reply
#32

(11-04-2019, 09:35 AM)Gary Wrote: if I remember correctly, I believe I previously experienced the same problem of losing session data when using the redirect() command in my code... but manage to side-step the issue at the time by using other ways to call the new page (without using the redirect() command directly).

I too am using out-ofbox settings and session data could be picked up in other php files of my app until I started to use a redirect() when I found all
 session data was lost in the redirected page.

I read about alternative redirect way to side-step issue and tried the header('Location...) solution but that also didn't work. I'm using PHP 7.4.5 and CI4.

Any advice welcome - thanks.
Reply
#33

I had the same problem... then I changed the config (in app/Config/App.php)

public $sessionSavePath = WRITEPATH . 'session';
to this:
public $sessionSavePath = '/tmp/';

Also double check if the WRITEPATH has the propper write permission.
Reply
#34

(This post was last modified: 07-07-2021, 09:47 AM by Gary.)

(05-21-2020, 02:57 AM)jim1001 Wrote:
(11-04-2019, 09:35 AM)Gary Wrote: if I remember correctly, I believe I previously experienced the same problem of losing session data when using the redirect() command in my code... but manage to side-step the issue at the time by using other ways to call the new page (without using the redirect() command directly).

I too am using out-ofbox settings and session data could be picked up in other php files of my app until I started to use a redirect() when I found all
 session data was lost in the redirected page.

I read about alternative redirect way to side-step issue and tried the header('Location...) solution but that also didn't work. I'm using PHP 7.4.5 and CI4.

Any advice welcome - thanks.

Sorry... being a bit of a noob and, at best, a complete hack on the computer, my visits to this site are sporadic... often with long interludes.  Not being an expert, I also don't bother subscribing to threads, because most of the time I don't have a lot to add.

At any rate, for those that end up on this page, searching for solutions in the future... quite a few things can cause the the session to get lost. Under the situation discussed in this thread, you could possibly try using < session_write_close(); > before you invoke header() or redirect().

The new versions of PHP close the session for writing more often than the earlier versions did... for example if < exit; > is used in the code... but I think there are still cases (like the two mentioned above) that it currently (may) not - which causes it to remain open and therefore blocked (essentially lost) for the new page one is redirecting to.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB