Store in session value from ajax post request

Hello everyone,

i don’t understand if this i doable, i’m trying to create an ajax request to pass some data to a controller and than store it in session.



 * Get data from localhost server


function getGSData() {

    return $.ajax({

        type: "get",

        dataType: 'json',

        url: "http://localhost",

        crossDomain: true,




 * Send data to framework


function sendGSData() {


    .done(function(gsdata) {



            type: "post",

            url: "actionURL",

            data: { gsdata: gsdata },







public function actionGsdata()


        if (Yii::$app->request->isAjax && Yii::$app->request->getIsPost()) {

            $gsdata = Yii::$app->request->post();

            Yii::$app->session['gsdata'] = $gsdata;



from console i can see the value with console.log(JSON.stringify(gsdata)); but no variable is stored.

Is it possible to do that or i’m just doing something wrong?


Ok, i solved it… i did just need to refresh the page in order to populate the session variable ::)