How to use Session on Form to Pull Data from Database

Hi everyone,

I would like to know how can I use session/session Id to pull data from one database table and save it to another database table. So, I have a form where users fill out their first/last names, date of birth to verify they qualify for competition. Then, if they do qualify, I want get their ID from DB and an email (prompted) and save those to a new table for pending contestant.

How can I do that or how to set that up?

SiteController




actionApply{


     if ($form->validate()) {

                Yii::$app->session->setFlash('success','valid');

         }

			 

	$session = Yii::$app->session;

			

                return $this->redirect(array('create'));

        }


        return $this->render('apply', array('form' => $form));

    }



Model for the apply




SELECT ID_NUM 

       FROM users

       JOIN members ON ID_NUM = ID_NUM

       WHERE FIRST_NAME = :first AND (LAST_NAME = :last OR BIRTH_NAME = :birthName) = :joinedYear

        ')->bindValues([

	    'id' => $this->alumId,

            ':first' => $this->firstName,

            ':last' => $this->lastName,

            ':birth' => $this->birthdate,

])->query() !==false;



So, I don’t know where to start and how.

Thanks!