1

応答ヘッダーに有効な「set-cookie」値を含むサーバー応答を受信すると、アプリケーションは Cookie を保存しません。

Heroku 上の Rails サーバーは、CORS (クロスドメイン ajax リクエスト) 用にセットアップされています。Access-Control-Allow-Credentials = True およびメソッド = POST、GET。

応答に set-cookie が含まれるログイン要求は次のとおりです。

 Ext.Ajax.request({
            url: 'http://myurl/log_user_in.json',
            params: { username: user, password: pass, app_id: id },
            method: "POST" });

アプリケーションが Cookie を保存しない理由について、ヘルプが必要です。すなわち。を実行する document.cookieと、「set-cookie」を取得した後、document.cookie = ''

ご協力いただきありがとうございます。

4

1 に答える 1

3

Found the answer here: https://stackoverflow.com/a/7189502/1106877

Unfortunately Sencha Forum answers provided almost no guidance on how to do this. In Sencha Touch, the equivalent solution to what the link above says is:

Ext.Ajax.request({
            url: 'http://myurl/log_user_in.json',
            params: { username: user, password: pass, app_id: id },
            withCredentials: true,
            useDefaultXhrHeader: false,
            method: "POST" });

It also works well with your store proxy using Ajax.

Ensure withCredentials is true and useDefaultXhreader is false. This permits your ajax request to look for, set, and request with cookies as available. Of course all this assumes your server is setup for Cross Domain Ajax calls.

于 2012-07-24T11:58:16.233 に答える