在基于IP的URL上设置Cookie [英] Set cookie on IP based URL

查看:1159
本文介绍了在基于IP的URL上设置Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在基于IP的URL上设置cookie,这是我的代码:

I want to set cookies on IP based URL.Here is my code:

if(check_login($_POST))    
{

    setcookie("client_id", $clientid, time()+3600*24*1, '/', '.domain.com');
    setcookie("email", $email1, time()+3600*24*1, '/', '.domain.com');
    setcookie("domain", $sdomain, time()+3600*24*1, '/', '.domain.com');
    setcookie("serverid", $serverid, time()+3600*24*1, '/', '.domain.com');
    setcookie("password", $password1, time()+3600*24*1, '/', '.domain.com');
    setcookie("current_login_status", $c_current_login_status, time()+3600*24*1, '/', '.domain.com');

    **Instead of above ,I want to set cookies like following**

    setcookie("client_id", $clientid, time()+3600*24*1, '/', '192.168.1.20');
    setcookie("email", $email1, time()+3600*24*1, '/', '192.168.1.20');
    setcookie("domain", $sdomain, time()+3600*24*1, '/', '192.168.1.20');
    setcookie("serverid", $serverid, time()+3600*24*1, '/', '192.168.1.20');
    setcookie("password", $password1, time()+3600*24*1, '/', '192.168.1.20');
}

请建议是否可能。

推荐答案

来自 http://www.perlmonks .org /?node_id = 128608


是否可以将cookie设置为IP地址而不是通常的www。 company.com?

Is it possible to set a cookie to an IP number instead of the usual www.company.com?

您也许可以设置cookie(即,将一些浏览器设置为
接受并存储它),但是我没有浏览器知道实际上
会将其退还给您。他们这样做的地方会引入一个巨大的
安全漏洞。

You might be able to set the cookie (that is, get some browser to accept and store it), but no browser that I know of will actually return it to you. Where they to do so, it would introduce a massive security hole.

请仔细考虑一下。可以为
.example.com设置cookie,浏览器将返回该cookie,以访问
example.com, www.example.com或 abcexample。 com。但是
.1.1呢?

Think about it for a moment. It's possible to set a cookie for ".example.com" that will be returned by a browser for visits to "example.com", "www.example.com", or "a.b.c.example.com". But what of ".1.1"? That would match sites all over the place.

因此从本质上讲,不会。

So esentially, no.

这篇关于在基于IP的URL上设置Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆