JQuery Ajax add data into php session

Permalink
How to add javascript data into php session

$.ajax({
type: 'POST',
url: '<?php echo $view->getThemePath()?>/elements/s_session.php ?>',
data: {'value': out}
})
.done(function(data){
alert(data);
window.location.href = 'ord_d';
}).error(function(er){
alert('error');
});


s_session.php
<?php
session_start();
if(isset($_POST)){
if (isset($_POST['value'])) {
$value = $_POST['value'];
$_SESSION['pdtmsr-qrcode'] = $value;
echo $_SESSION['pdtmsr-qrcode'];
}
}
?>

 
JohntheFish replied on at Permalink Reply
JohntheFish
The generic solution is to create a route to a controller, then in the controller add the post data to the session, ideally using the request object (rather than superglobals).

For block controllers, you can shortcut the route creation by using a block action.

In the documentation, the topics to read up on are routes, on_start event handlers, block actions and ajax.
davidkham replied on at Permalink Reply
Thanks for the reply.
I'm using express_form custom template and how to go and to send to controller from javascript with data.
Please explain detail me with the code.