是否可以在PHP中为setcookie()定义两个URL?

问题描述 投票:0回答:1

我有三种连接到我的网页的方法:外部IP,内部IP或域名。

我正在学习有关登录“记住我的功能”的信息,但实际上对此了解不多。

某些代码

//Define WEBSITE to use it in the cookie.
define ("WEBSITE",'123.12.1.123');

//set the cookie
$setc = setcookie(
    'remember',
     $selector.':'.base64_encode($authenticator),
     time() + 864000*7,
     '/',
     WEBSITE,
     false, // TLS-only set to true if u have a website on https://
     false  // http-only
);

我现在注意到,如果我转到定义的网站123.12.1.123,则可以在登录时设置cookie。但是,如果我使用内部IP,则无法设置Cookie:192.12.1.123

是否可以使用多个地址?还是应该解决这个问题?

需要更多代码吗?只是要求它!

php cookies
1个回答
0
投票

出于安全原因,网站无法在其他域上设置或检索Cookie。您可以做的最接近的事情是使Cookie可用于单个域的所有子域。

© www.soinside.com 2019 - 2024. All rights reserved.