As designed Session is not created

RisteDimitrievski

Active member
Affected version
2.2.8 PL1
For some reason sessions created while executing ajax post request won't be created. Here is an example
PHP:
 public function actionPostSession(){
        $data = $this->filter('metamaskid','str');
        if(!empty($data)){
            $this->session()->set('metamask_id', $data);
            return $this->apiResult(['code' => 201,'message' => $data]);
        }else{
            return $this->apiResult(['errorCode' => 404,'message' => 'Session not created!']);
        }
    }

This is an API request, when i execute ajax.
The below code is service that i've extended to set metamask ID in registration.
PHP:
public function saveStateToSession(\XF\Session\Session $session)
    {
        $data = parent::saveStateToSession($session); // TODO: Change the autogenerated stub
        $session->set('registration',['metamask_id' => $session->get('metamask_id')]);
        return $data;
    }

The below code is the controller i'm extending (\XF\Pub\Controller\Register)
PHP:
 public function actionRegister()
    {
        $metamaskid = \XF::session()->get('metamask_id');
        if(empty($metamaskid) || $this->finder('XF:User')->where('metamask_id','=',$metamaskid)->fetchOne()){
            return $this->error(\XF::phrase('metamask_error'));
        }
        return parent::actionRegister(); // TODO: Change the autogenerated stub
    }

I've extended existing authentication and created new functions for these service to check for login.
It prints empty $metamaskid variable.

Any idea?
 
Top