*興味がある場合は、この投稿へのコメントとして、この問題に関する Foursquare からの回答をご覧ください*
助けてください、私はまだこれと戦っています:(
Foursquare 関連の Cookie をすべて削除するボタンを作成しました。Firebug で確認したところ、クリックすると Cookie の設定が解除されました。
また、同じプログラミングにより、ユーザーが最初にログインしたときにデータベースに挿入されたトークンが削除されます。データベースにチェックインすると、行が削除されます。
そして、何が起こるかは次のとおりです。
- Cookie のない新しいブラウザーで、ユーザーがログインします。
- Cookie が設定され、トークンとユーザー ID を含む行がデータベースに挿入されます。
- ユーザーがログアウトします。
Cookie の設定が解除され、データベースから行が削除されました
<a href='".$authorizeUrl."'>Log in</a>
ここで、別のユーザーがログインしようとしています。彼/彼女は私の Web アプリをクリック します。Foursquare ログイン ページが表示されますが、フォームに入力する前に、ページは以前のユーザー トークンと情報を使用して Web アプリにリダイレクトされます。
ポイント6が発生せずにクリーンスタートを行う唯一の方法は、ブラウザーからすべてのCookieを手動で削除することです:(
どこに従うべきかわかりません。私が使用しているコードの下で、ステップ 6 がどのように行われるかを試してみてください。
ありがとうございます
<?php
ob_start();
require_once('includes/EpiCurl.php');
require_once('includes/EpiSequence.php');
require_once('includes/EpiFoursquare.php');
$logout= $_GET['logout'];
if ($logout == 'true'){ /*I'm deleting all the cookies foursquare related just in case*/
$pastdate = mktime(0,0,0,1,1,1970);
setcookie ("XSESSIONID", "", time() - 18600);
setcookie ("access_token", "", time() - 18600);
setcookie ("ext_id", "", time() - 18600);
setcookie ("LOCATION", "", time() - 18600);
setcookie("access_token", "", $pastdate);
setcookie("XSESSIONID", "", $pastdate);
setcookie("ext_id", "", $pastdate);
setcookie("LOCATION", "", $pastdate);
setcookie("_chartbeat2", "", $pastdate);
setcookie("__utmb", "", $pastdate);
setcookie("__utmc", "", $pastdate);
setcookie("__utma", "", $pastdate);
setcookie("__utmz", "", $pastdate);
$_SESSION['XSESSIONID']=false;
unset($_SESSION['XSESSIONID']);
}
$clientId = "yyyyyyyyy";
$clientSecret = "xxxxx";
$redirectUrl = 'mypage.php';
$fsObjUnAuth = new EpiFoursquare($clientId, $clientSecret);
$thecode = $_GET['code'];
if(!isset($thecode) && !isset($_COOKIE['access_token'])) { //not in yet
$authorizeUrl = $fsObjUnAuth->getAuthorizeUrl($redirectUrl);
echo"<a href='".$authorizeUrl."'>Let's log in</a>";
}else{ /*we're in*/
if(!isset($_COOKIE['access_token'])) {
$token = $fsObjUnAuth->getAccessToken($thecode, $redirectUrl);
setcookie('access_token', $token->access_token);
$_COOKIE['access_token'] = $token->access_token;
}
$fsObjUnAuth->setAccessToken($_COOKIE['access_token']);
echo "we're in";
echo"<br><a href='mypage.php?logout=true'>Logout</a>";
}
?>