簡體   English   中英

會話在郵件驗證注冊中不起作用

[英]session doesn't work in mail verification register

我使用電子郵件驗證進行注冊。 注冊后,我登錄用戶並在會話中保留其ID(我有一個用於存儲用戶登錄信息的會話類),然后發送鏈接到他的郵件,畢竟我將用戶重定向到另一個頁面,並告訴他請檢查您的郵件並單擊。 ...

這是我發送給用戶郵件的鏈接(目前,我默認情況下只是發送給我的郵件)

$body.="<h4><a href='http://www.habibabdollahi.com/fani/home/activate.php?user=".$user->id.
                "&code=".$user->mail_verify_code."'>فعال سازی</a></h4>";    

在activate.php中,我用用戶名和代碼驗證用戶,但單擊郵件中的鏈接后,似乎無法訪問會話。 但是,如果如果將用戶重定向到像最后一個鏈接一樣的Activate.php注冊后,則沒有問題,在這種情況下,我有會話。

redirect_to("home/activate.php"."?user=$user->id&code=$user->mail_verify_code");

有什么問題的朋友,我要瘋了!

只專注於會話,我只想知道為什么通過郵件重定向后我的會話丟失了,這是我的會話類

class Session{

    public $user_id;
    private $loged_in=false;
    private $verified_mail=false;
    private $verified_mobile=false;
    private $user_type; 


    function __construct(){
        session_start();
        $this->check_login();
        $this->check_verification();// ham mobile va ham mail ra check mikonad
        $this->check_user_type();
    }

    /* It'es get method, that get the loged status  */
    public function is_logged_in(){
        return $this->loged_in;     
    }

    public function login($user){
        //database should find user based on username and password
        if($user){
            $this->user_id=$_SESSION['user_id']=$user->id;
            $this->loged_in=true;
        }
    }

    public function verify_mobile($is_verified){
        if($is_verified){
            $this->verified=$_SESSION['verified_mobile']=$is_verified;
        }else{
            return false;   
        }
    }

    public function verify_mail($is_verified){
        if($is_verified){
            $this->verified=$_SESSION['verified_mail']=$is_verified;
        }else{
            return false;   
        }
    }
    /******  user type ra be khater miseparad    *********************/
    public function remember_user_type($user){
            if($user){
                $this->user_type=$_SESSION['user_type']=$user->user_type_id;
            }
    }
    public function get_user_type(){

        return $this->user_type;    
    }


    private function check_user_type(){
        if(isset($_SESSION['user_type'])){
            $this->user_type=$_SESSION['user_type'];
        }

    }
    // che mobile va ya che mail verify shode bashad okeye
    public function get_is_verified(){
        return ($this->verified_mobile || $this->verified_mail);
    }

    public function get_is_verified_mobile(){
        return $this->verified_mobile;      
    }

    public function get_is_verified_mail(){
        return $this->verified_mail;        
    }

    public function logout(){
        unset($_SESSION['user_id']);
        unset($this->user_id);
        $this->loged_in=false;
    }

    public function get_user_id(){
        return $this->user_id;  
    }

    private function check_login(){

        if(isset($_SESSION['user_id'])){
            $this->user_id=$_SESSION['user_id'];
            $this->loged_in=true;

        }else{
            unset($this->user_id);
            $this->loged_in=false;
        }

    }//check_login

    private function check_verification(){

        if(isset($_SESSION['verified_mail'])){
            $this->verified_mail=$_SESSION['verified_mail'];
            //$this->verified=true; 
        }

        if(isset($_SESSION['verified_mobile'])){
            $this->verified_mobile=$_SESSION['verified_mobile'];
            //$this->verified=true;
        }

    }


}//class end

$session=new Session();
//var_dump($session);

你可以試試這個

if(isset($_SESSION['user_id'])){
        $this->user_id=$_SESSION['user_id'];
        $this->loged_in=true;

    }

代替

if(isset($_REQUEST['user'])){
        $this->user_id=$_REQUEST['user'];
        $this->loged_in=true;

    }

由於使用url傳遞user參數

$body.="<h4><a href='http://www.habibabdollahi.com/fani/home/activate.php?user=".$user->id.
                "&code=".$user->mail_verify_code."'>فعال سازی</a></h4>";  

在驗證碼刷新會話並將用戶重定向到登錄頁面之后,當用戶要登錄時,請檢查用戶是否處於活動狀態,然后將所有用戶數據發送到會話Array我不是專家,但請提供建議

首先獲取您選擇登錄的用戶身份ID

然后將這些ID發送給登錄功能,然后進行會話

試試看

private function check_login($userID){
     Used Fetch Query there for login authentication and then give him to session ...       
your session code is here.........................  and redirect or return true   
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM