Welcome Guest, Not a member yet? Register   Sign In
Flashdata and AJAX calls on every page load

(This post was last modified: 01-16-2016, 07:50 PM by komirad.)

My app has an AJAX request on every page load. (Notifications)

This has made the flashdata feature pretty useless for the rest of the code. As you know flashdata is deleted on the next request, and the ajax call deletes my flashdata.

I have worked around this by looping through all the flashdata and calling keep_flashdata() so that the AJAX request doesn't delete any flashdata.

Is there a better way to handle this?

Maybe a way to say
PHP Code:
// Set flash data to not delete.

Or should I create my own flashdata library so that I can have different sets of flashdata that can have different configurations? The problem with this is third party libraries will all have to modified.

You can have a look at: https://github.com/jenssegers/codeignite...ge-library

It's very easy to have your own type of flash data that only removes entries when you fetch than and they are used. I have adopted my own version with some added pre formatted output for some fancy bootstrap3 type alert messages.

(This post was last modified: 01-17-2016, 07:00 PM by komirad.)

Just had a look at it.

I am using ion_auth which uses flashdata for csrf as seen here: https://github.com/benedmunds/CodeIgnite...s/auth.php $this->session->set_flashdata('csrfkey', $key)

I have to update that controller code to adopt another flashdata like library. And it does look like, I have to do the same with any other library that uses flashdata Sad

Theme © iAndrew 2016 - Forum software by © MyBB