Php 基于ssl的用户登录系统cookie

Php 基于ssl的用户登录系统cookie,php,cookies,login,remember-me,Php,Cookies,Login,Remember Me,我创建了用户登录系统,并使用此功能启动会话 function sessionStart() { $session_name = 'sec_session_id'; // Set a custom session name $secure = false; // Set to true if using https. $httponly = true; // This stops javascript being able to access the session id.

我创建了用户登录系统,并使用此功能启动会话

function sessionStart() {
    $session_name = 'sec_session_id'; // Set a custom session name
    $secure = false; // Set to true if using https.
    $httponly = true; // This stops javascript being able to access the session id. 

    ini_set('session.use_only_cookies', 1); // Forces sessions to only use cookies. 
    $cookieParams = session_get_cookie_params(); // Gets current cookies params.
    session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httponly); 
    session_name($session_name); // Sets the session name to the one set above.
    session_start(); // Start the php session
    session_regenerate_id(true); // regenerated the session, delete the old one. 
}
我使用会话cookie,正如您在我上面的菜单中看到的一样,我将此会话存储在memcached中以增强我的操作。现在我需要创建一个cookie,将用户数据存储在其中。例如,我需要用户id,然后我将用户id存储在cookie中,如下所示

setcookie('userid','1234',time()+240000)
之后,我需要用户密码和用户名,以防用户登录。但我知道我不应该在cookie中保留密码。如果在我们的服务器因使用memcache而崩溃时不在cookie中保留密码,我们将失去所有用户会话。我说得对吗?那么我应该如何让用户登录..请解释一下。无需麻烦您自己编写代码


提前感谢

我建议您将客户端登录的数据保存在SQL数据库中,并给SQL行一个随机salt+哈希,然后将该哈希分配给cookie。然后每次只需从数据库中获取信息