我在Ruby on Rails中完成了一個處理用戶身份驗證的站點。現在我在一個子文件夾下的同一個站點上有一個PHP應用程序,它檢索由RoR提供的JSON指定用戶角色的JSON。檢索JSON維護瀏覽器會話
現在,當我試圖從PHP中檢索JSON時,即使用戶登錄(我相信因爲瀏覽器會話未被維護),它始終會以'Guest'的形式檢索。我用它來檢索JSON的代碼是
$json_url = 'https://mysite.com.com/usertype';
$json_string = '[usertype]';
// Initializing curl
$ch = curl_init($json_url);
// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
CURLOPT_POSTFIELDS => $json_string
);
// Setting curl options
curl_setopt_array($ch, $options);
// Getting results
$result = curl_exec($ch); // Getting jSON result string
現在是有什麼人能幫助我在哪裏我可以檢索JSON維護會話????
的http://計算器。 com/questions/3097451/sharing-a-session-between-ruby-and-php – LeonardChallis
這兩個應用程序位於同一個域中,不存在涉及的子域。那麼,有沒有更簡單的方法? – holyidiot
該答案的第一部分不是域特定的,將工作 – LeonardChallis