CodeIgniter Forums
Page not loading if session is enabled!! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Page not loading if session is enabled!! (/thread-76493.html)



Page not loading if session is enabled!! - webdevron - 05-17-2020

I have developed web application using Beta version of CI4. Now I am updating this to current version. But surprisingly the session is not working.


Here is the sample code.
PHP Code:
<?php if(session('cart')):?>
        <span class="badge badge-cnapp rounded-sm small-70 float-left">
                <?php echo count($session->cart)?>
        </span>
<?php endif;?>

If I load the website with the above code, the browser is showing:

Quote:Hmmm… can't reach this page
The connection was reset.

But if I comment out the above code like bellow, everything is working fine:

PHP Code:
<?php // if(session('cart')):?>
        <span class="badge badge-cnapp rounded-sm small-70 float-left">
                <?php //echo count($session->cart)?>
        </span>
<?php //endif;?>


[Image: Output.png]


RE: Page not loading if session is enabled!! - hsalardi - 05-17-2020

Hello,

Try this:

<?php if(session()->has('cart')):?>

Regards


RE: Page not loading if session is enabled!! - SNebiyev - 05-17-2020

I assume that you have got php errors. Please enable php errors.


RE: Page not loading if session is enabled!! - webdevron - 05-18-2020

(05-17-2020, 04:52 PM)hsalardi Wrote: Hello,

Try this:

<?php if(session()->has('cart')):?>

Regards

Nothing changed!!

(05-17-2020, 10:41 PM)SNebiyev Wrote: I assume that you have got php errors. Please enable php errors.

PHP error has been enabled. As the environment is Development, so debugging ang error logging in on. Everything is perfect and showing other errors but in this case, page is loading for a while and then showing that window.