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?



     if ($form->validate()) {




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


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


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


Model for the apply


       FROM users

       JOIN members ON ID_NUM = ID_NUM

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


	    'id' => $this->alumId,

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

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

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

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

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