2

I have tried setting cookies but the problem is in setting domain. When i tried to set domain in setcookies() it doesn't set any value. Without domain setting it will automatically set my domain (for ex. localhost).

If I am using any .com it will set it by default but I cannot set domain in cookies.

Can any one please help me setting domain in php.

  setcookie('session_id',$sessionID[1],strtotime($expireTime[1]),'/',$domain);

When I set it without domain it sets the cookies to my localhost or on which domain I am.

Can any one help me.

4

2 に答える 2

1

使用しているドメイン以外のドメインに帰属するCookieを設定することはできません。これは一般的に良いことだと考えられています。

于 2012-10-30T12:18:30.930 に答える
1

ドメインを に配置するとsetcookie、PHP が適切なドメイン名で Cookie を設定したことがヘッダーに表示されます。ただし、ブラウザは安全上の理由から無視します。

自動ログインなどのために Cookie を設定する必要がある場合は、hosts ファイルを操作して、Cookie を設定するドメインと同じドメインにいるとブラウザに認識させる必要があります。

例 :

追加する場合:

127.0.0.1   autologin.amazon.co.uk

をホスト ファイルに追加し、http://autologin.amazon.co.uk代わりに に移動するとhttp://localhost、リモート スクリプトで任意の.amazon.co.ukCookie を設定できるようになります。

于 2012-10-30T12:27:34.153 に答える