Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class User {
- public $logged = false;
- public function __construct(){
- global $db;
- if(isset($_COOKIE['logged'])){
- $auth = explode(':', base64_decode($_COOKIE['logged']));
- $sql = $db->prepare("SELECT * FROM users WHERE id = :id and password = :password LIMIT 1");
- $sql->execute(array(':id' => $auth[0], ':password' => $auth[1]));
- $check = $sql->fetchColumn();
- $user = $sql->fetch(PDO::FETCH_ASSOC);
- var_dump($check);
- var_dump($user);
- if ($check == true) {
- $this->logged = true;
- $this->id = $user['id'];
- $this->firstname = $user['firstname'];
- $this->secondname = $user['secondname'];
- }
- }
- }
- # получаем ид
- public function getID(){
- return $this->id;
- }
- # получаем имя и фамилию
- public function getFirstName(){
- return $this->firstname;
- }
- public function getSecondName(){
- return $this->secondname;
- }
- }
- $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement