Welcome Guest, Not a member yet? Register   Sign In
Security exception when cache is passed as view parameter
#1

Using 4.4.6, I'm getting a "CodeIgniter\Security\Exceptions\SecurityException #403" on a POST, when I submit a form. This only happens if I load the view(s) like this:

PHP Code:
$view_cache = ['cache' => nn]
return 
view'templates/header'$data$view_cache )
         view'login/signup'$data$view_cache )
         view'templates/footer'$data$view_cache ); 

It doesn't matter if I set nn to zero or 60. If I change "cache" to "xcache" (which I'm guessing is simply ignored), everything works.

What am I doing wrong?

-joho
Reply
#2

Your passing the data and cache multiple times, you only need to pass it once.

always pass the data in the first view, then it is available to all other views.

Try this, it's how I load the views.

PHP Code:
$view_cache = ['cache' => nn'cache_name' => 'login_signup']

return 
view'templates/header'$data$view_cache )
        view'login/signup' )
        view'templates/footer' ); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

You cannot cache HTML forms with CSRF token.
CSRF tokens cannot be shared with others.
Reply
#4

(03-25-2024, 04:08 AM)kenjis Wrote: You cannot cache HTML forms with CSRF token.
CSRF tokens cannot be shared with others.

Fair enough, that makes sense. But why does it start behaving so strange when I pass it a 'cache' parameter with a setting of zero? Shouldn't that be the same as not caching at all?

-joho
Reply
#5

Yes, if you set zero, the cache should be expired at the moment and should not be used.
So I don't know why you get the SecurityException.
Reply
#6

(03-25-2024, 03:52 AM)InsiteFX Wrote: Your passing the data and cache multiple times, you only need to pass it once.

always pass the data in the first view, then it is available to all other views.

Yes, you're right of course, I really should do that the correct way.

-joho
Reply




Theme © iAndrew 2016 - Forum software by © MyBB