CodeIgniter Forums
session('something') fails intemittently - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: session('something') fails intemittently (/showthread.php?tid=77295)



session('something') fails intemittently - 68thorby68 - 08-12-2020

Hi,

Part of my project adds an array to the session, which I use on nearly every view in my project.

in my view i access the array
PHP Code:
<?php foreach(session('items') as $arrayKey => $arrayValue) : ?>

                my item: <?= esc($arrayKey?>
                item value: <?= esc($arrayValue?>
    
             <?php endforeach ?>
Literally, and all of a sudden, every reference to session('item') stops working, in every views, generating (exception s where relevant)

However, if i run print_ in the asscociated controller:
PHP Code:
print_r($this->session-get('item')); 
The session and all of it's content arrays are intact.

As this piece of code is critical to my project it was created some time ago and is never (NEVER) touched.

Is their any reason why session('') would just stop?

Now here's the thing, I thought I maybe somehow be overloaeding the session (adding content / removing content).
So I destroyed the session. - This didnt fix the issue
I closed/restarted the browser - This didnt fix the issue
I restarted the server (hard boot) - This didnt fix the issue

But after all of this, about 2 hours after I first experienced the exceptions, everything all of a sudden works again, and I promise that apart from adding a few print_r here and there, and destroying and restarting sessions I have not changed a thing to my code, CI config or ther server.

Any ideas?????


RE: session('something') fails intemittently - InsiteFX - 08-13-2020

Did you view the server error log files to see if there where any errors?

This could be anything, running out of memory or to large of a cookie.

I would view the server error logs to see if any errors where reported.