Php 保存用户';将oauth键放入cookie中
我使用oauth将我的web应用程序连接到twitter。它工作正常,但我需要定期重新授权该应用程序 我将密钥保存在会话中,但当用户关闭页面时,这些密钥似乎会消失 我应该将密钥保存在其他cookie中吗Php 保存用户';将oauth键放入cookie中,php,cookies,twitter,oauth,Php,Cookies,Twitter,Oauth,我使用oauth将我的web应用程序连接到twitter。它工作正常,但我需要定期重新授权该应用程序 我将密钥保存在会话中,但当用户关闭页面时,这些密钥似乎会消失 我应该将密钥保存在其他cookie中吗 function access_token($tmhOAuth) { $tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token']; $tmhOAuth->config['user_secret']
function access_token($tmhOAuth) {
$tmhOAuth->config['user_token'] = $_SESSION['oauth']['oauth_token'];
$tmhOAuth->config['user_secret'] = $_SESSION['oauth']['oauth_token_secret'];
$code = $tmhOAuth->request(
'POST',
$tmhOAuth->url('oauth/access_token', ''),
array(
'oauth_verifier' => $_REQUEST['oauth_verifier']
)
);
if ($code == 200) {
$_SESSION['access_token'] = $tmhOAuth->extract_params($tmhOAuth->response['response']);
unset($_SESSION['oauth']);
header('Location: ' . tmhUtilities::php_self());
} else {
outputError($tmhOAuth);
}
}
您可以将密钥保存在cookie中,确保将cookie过期时间设置为足够长的时间,或者在持久数据库中存储任意长的时间