【问题标题】:wordpress cookies wild cardwordpress cookie 通配符
【发布时间】:2012-12-21 10:45:15
【问题描述】:

wordpress 将 cookie 命名为

wordpress_logged_in_bbfa5b726c6b7a9cf3cda9370be3ee91

_in 之后的部分对于每个用户都是不同的。有没有办法可以在

中使用通配符
$_COOKIE["wordpress_logged_in_bbfa5b726c6b7a9cf3cda9370be3ee91"]

有点像

$_COOKIE["wordpress_logged_in_%"]

【问题讨论】:

  • 有什么用途?我不明白

标签: php wordpress cookies


【解决方案1】:

您必须遍历整个 $_COOKIE 数组以查看它是否与模式匹配:

$matches = array();
foreach($_COOKIE as $key => $value) {
  if(substr($key, 0, 20) == 'wordpress_logged_in_') {
    $matches[] = $key;
  }
}
//$matches now contains the key of all matching cookies

【讨论】:

    猜你喜欢
    • 2011-12-22
    • 1970-01-01
    • 2018-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-18
    • 2011-08-07
    • 1970-01-01
    相关资源
    最近更新 更多