简体   繁体   English

无法删除PHP中的$ _COOKIE返回的编码(在MAMP服务器上)

[英]Can't remove encoding returned in $_COOKIE in PHP (on MAMP Server)

I finally got cookies to work only for my output to display like this: 我终于让cookie起作用了,只能让我的输出显示如下:

You last requested an internship opportunity on Wednesday%2C+November+15%2C+2017%2C+3%3A+33+AM. 您上次要求在星期三%2C +十一月+ 15%2C + 2017%2C + 3%3A + 33 + AM实习的机会。

I have tried using urldecode(),rawurldecode(), setrawcookie(), implode(), and explode(). 我尝试使用urldecode(),rawurldecode(),setrawcookie(),implode()和explode()。 None of these have had any affect on the output, and I haven't seen other suggestions in similar questions. 这些都没有对输出产生任何影响,在类似的问题中我还没有看到其他建议。 If anyone has an idea of what might work, I would appreciate the information. 如果有人对可能有用的方法有所了解,我将不胜感激。

Below I have included some of the code (there's two files involved so I won't post those unless necessary). 下面,我包括了一些代码(涉及到两个文件,因此除非必要,否则我不会发布它们)。

Cookie info pulled from top of page 从页面顶部提取Cookie信息

if(isset($_COOKIE['LastRequestDate']))
    $LastRequestDate = $_COOKIE['LastRequestDate'];
else
    $LastRequestDate = "";

Cookie variable displayed Cookie变量显示

echo "<p>You last requested an internship opportunity on ".$LastRequestDate."</p>";

Here's the code that set's the cookie from another page. 这是从另一个页面设置cookie的代码。 I have tried removing the urlencode() but nothing changes. 我尝试删除urlencode(),但没有任何变化。

setcookie("LastRequestDate", urlencode($DisplayDate), time()+60*60*24*7, "/");

use: 采用:

<?php
  $DisplayDate = date("l jS \of F Y h:i:s A") ;
  $base64 = base64_encode($DisplayDate);

  setcookie("LastRequestDate", $base64, time()+60*60*24*7, "/");

  $LastRequestDate = $_COOKIE['LastRequestDate'];
  echo base64_decode($LastRequestDate);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM