Welcome Guest, Not a member yet? Register   Sign In
A session on $_SESSION
#1
Question 
(This post was last modified: 06-24-2021, 04:07 PM by Gary.)

I'm usually paranoid and have:   $session = \Config\Services:: session();  in most routines that I am referencing $_SESSION in.

This appears to be necessary, otherwise I find that sometimes the $_SESSION variables (like those denoting the user is signed in) go missing for a while, and the user looses some of their signed-in privileges, even though they're not signed out.

I have found that sometimes, thought different happenings, that some routines requiring $_SESSION don't have this initialization, and don't appear to have ever caused a problem in the past.

Having recently moved my little project from a Windows machine onto a Linux box, although initially there didn't seem to be a problem with $_SESSION becoming lost, as of late it's become a horrible irritation.  To be fair, perhaps I've broken something somewhere... though, it appears to become lost at random intervals, even when there is no user activity (besides the background (automated) 1-minute connection-check polling from the client side using JavaScript).

My questions are as follows:

    1)  Is there a better way / place to invoke the $session =... initialization than in every function/method that I use it (sticking it in BaseController didn't seem to work for me in the past)?

    2)  At some point in the past I thought using this to initialize it would be more sensible:
              if (!isset($_SESSION))  $session = \Config\Services:: session();
        I found it didn't work very well (and $_SESSION still appeared to go AWOL from time-to-time).  I'd be grateful if anyone could explain why, and perhaps also suggest a better way to (conditionally) reattach $_SESSION's handle.

Thanks.
Reply


Messages In This Thread
A session on $_SESSION - by Gary - 06-24-2021, 04:06 PM
RE: A session on $_SESSION - by superior - 06-25-2021, 07:50 AM
RE: A session on $_SESSION - by Gary - 06-26-2021, 03:26 PM
RE: A session on $_SESSION - by InsiteFX - 06-26-2021, 08:46 PM
RE: A session on $_SESSION - by MGatner - 06-27-2021, 04:52 AM
RE: A session on $_SESSION - by Gary - 07-03-2021, 01:57 PM
RE: A session on $_SESSION - by InsiteFX - 07-03-2021, 09:02 PM
RE: A session on $_SESSION - by Gary - 07-06-2021, 12:26 PM
RE: A session on $_SESSION - by Gary - 07-07-2021, 04:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB