Exemple #1
0
 public function checkId(User $user, userMapper $usermapper, $cookie)
 {
     //connecting db
     $user->cookie = $cookie;
     $result = $usermapper->selectCookie($user);
     //checking if the user with that cookie already exists
     // var_dump($result);
     if (empty($result)) {
         //if the user doesn't exist we create the user with that cookie
         $usermapper->save($user);
         $result = $usermapper->selectCookie($user);
         //then we get an id of the user with the cookie we've just saved
         // var_dump($result);
     }
     $user_id = $this->getUserId($result);
     return $user_id;
 }