Vish:
私は、Webサーバーに独自のデータベースを持っているAndroidアプリを開発しています。私は、ログに1つの活動のセッション、セッション変数は、次のアクティビティに渡されません作成したときに私の問題はあります。
私が使用しHttpURLConnection
、次のように両方の活動での接続を確立します。(URLのパラメータを変更します)
URL url = new URL(si_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
私の第二のPHPファイルでは、isset( $_SESSION['memberid'] )
返し偽。
<?php
require "conn.php";
session_start();
$value = $_SESSION['memberid'];
if(isset($_SESSION['memberid'])){
echo (string)$_SESSION['memberid'];
}
else {
echo "Error!";
}
?>
私は2つの活動のための2つの異なる接続を作成するため、この問題が発生した疑いがあります。このため、任意のソリューション?
Vish:
使って解きます CookieManager
CookieManager cookieManager = new CookieManager();
try{
CookieHandler.setDefault(cookieManager);
}catch(UnsupportedOperationException ex){
ex.printStackTrace();
}
それが実行される前に、ちょうどあなたのアプリのどこかにこのコードを置きます HttpURLConnection