Welcome Guest, Not a member yet? Register   Sign In
PHP Cookies & CI4 Page Caching
#1

Does anyone know if session variables and data work when page caching is enabled?
Reply
#2

(11-26-2021, 04:30 PM)JessycaFrederick Wrote: Does anyone know if session variables and data work when page caching is enabled?

You need to clarify your question. Look at this code:
PHP Code:
public function mypage()
{
session()->set('foo''foo value before cache');
$this->cachePage(120); // 2 minutes
return view('foo_view');


In your view file just insert foo value from session and open mypage. On the first load you'll see 'first foo value before cache' and CI will cache this page for 2 minutes. Then in your code change value of foo to something else (for example: foo value changed by me after page cached), save your code and reload mypage.
You'll get old value of foo, not your modified new one. You can reload and reload again, content will be same. But after 2 minutes passed foo value will be changed to your new one.
I think this is the answer to your question if i don't get you wrong.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB