yii2 guest not possible to make a post request

Helloy guys, i need your help, im using yii2.

im increasing a session variable everytime the user / guest is reloading a site, with an auth user it works but not with the guest, the guest has the right to join the actions in controller. Do i have to give the guest role a right to do post requests? here you can see my behavoirs method, but its not working.


 public function behaviors() {

        return [

            'access' => [

                'class' => AccessControl::className(),

                'only' => ['actionPruefungstarten', 'actionTeilnehmerauswahlspeichern', 'actionSp', 'actionIndex', 'actionStartdashboard'],

                'rules' => [

                    [

                        'allow' => true,

                        'verbs' => ['POST'],

                        'roles' => ['?'],

                    ],

                    [

                        'allow' => true,

                        'roles' => ['@'],

                    ],

                ],

            ],

        ];

    }

I don’t understand what are you saying but if don’t want the Guest to post/create something you can use this:




public function behaviors()

    {

        return [

            'access' => [

                'class' => AccessControl::className(),

                'only' => ['create', 'update', 'delete'],

                'rules' => [

                    [

                        'allow' => true,

                        'roles' => ['@']

                    ],

                ]

            ],

            'verbs' => [

                'class' => VerbFilter::className(),

                'actions' => [

                    'delete' => ['POST'],

                ],

            ],

        ];

    }



The code basically tells that if the user have not logged in then the user cannot ‘create’, ‘update’, delete.