I have an ajax call which fires right when the DOM has finished loading, yet I am trying to prevent a situation when the user hits refresh and fires that ajax call again by storing a session variable. Yet, there seems to be an issue with storing a session entry via AJAX request, consider the following snippet:
<?php
function postMyAjax() {
$already_fired = \Session::get('ajax_fired'); // <-- Always returns NULL!
if ( ! empty( $already_fired ) ) {
return Response::json(array('already fired'));
}
# Remember that we fired that call
\Session::put('ajax_fired',1); // <-- Fails to set?
return Response::json(array('ok'));
}
Any ideas?