我的Firefox中是否设置了我的cookie?

时间:2016-01-14 08:02:54

标签: php cookies sqlite

Lamp安装在我的本地电脑上,其操作系统是debian8 也就是说客户端和服务器都安装在我的本地电脑上 以下代码在我的本地电脑上保存为setcookie.php。

<?php
setcookie("user", "Alex Porter", time()+36000);
?>

<html>
<body>

</body>
</html>

现在php setcookie.php已在我的本地电脑上执行。 以下代码全部在我的本地电脑上执行。

find /  -name   "cookies.sqlite"
/home/debian8/.mozilla/firefox/joww2h34.default/cookies.sqlite

sqlite3  /home/debian8/.mozilla/firefox/joww2h34.default/cookies.sqlite
sqlite> .tables
moz_cookies
sqlite>     PRAGMA table_info([moz_cookies]);
0|id|INTEGER|0||1
1|baseDomain|TEXT|0||0
2|appId|INTEGER|0|0|0
3|inBrowserElement|INTEGER|0|0|0
4|name|TEXT|0||0
5|value|TEXT|0||0
6|host|TEXT|0||0
7|path|TEXT|0||0
8|expiry|INTEGER|0||0
9|lastAccessed|INTEGER|0||0
10|creationTime|INTEGER|0||0
11|isSecure|INTEGER|0||0
12|isHttpOnly|INTEGER|0||0

sqlite>     select *  from moz_cookies where name="Alex Porter";
sqlite> select *  from moz_cookies where name="user";

为什么没有为这两者选择信息?
在我的Firefox中设置或不设置我的cookie吗? 如果在我的firefrox上设置,为什么不能在sqlite语句中选择?
在我看来,sql命令select * from moz_cookies where name="Alex Porter";将得到像

这样的东西
name  user  value Alex Porter  expires 1515832198

什么都没显示。 按照Aadil P.的说法将文件保存为/var/www/html/tmp/setcookie.php中的setcookie.php。 在firefox中执行了127.0.0.1/tmp/setcookie.php 用firebug打开Cookies。

enter image description here

此处显示正确的结果。
还有两个问题:
1.饼干的字段多少?

PRAGMA table_info([moz_cookies]);
0|id|INTEGER|0||1
1|baseDomain|TEXT|0||0
2|appId|INTEGER|0|0|0
3|inBrowserElement|INTEGER|0|0|0
4|name|TEXT|0||0
5|value|TEXT|0||0
6|host|TEXT|0||0
7|path|TEXT|0||0
8|expiry|INTEGER|0||0
9|lastAccessed|INTEGER|0||0
10|creationTime|INTEGER|0||0
11|isSecure|INTEGER|0||0
12|isHttpOnly|INTEGER|0||0

在firebug cookies寡妇中只有名称,价值,域名,原始大小,路径,过期,httponly,安全性。
为什么它们不一样?相关国际标准中有多少个cookie元素?

2.如何编写正确的sql命令?

select *  from moz_cookies where name="user";
select *  from moz_cookies where Name="user";

他们两个都什么都没得到。

2 个答案:

答案 0 :(得分:6)

您正在使用php setcookie.php通过cli执行php文件(根据您的评论)。 Cookie或HTTP Cookie存储在用户的网络浏览器中.... [根据维基百科 - https://en.wikipedia.org/wiki/HTTP_cookie]

你需要在CL中提到的浏览器中打开/执行这个php文件。

由于您已安装LAMP,请将脚本(php文件)移至LAMP文件夹并通过调用该文件在浏览器中打开该页面,您的网址地址栏应如http://localhost/setcookine.php(or http://127.0.0.1/ / setcookie .php)或类似的东西取决于文件的位置。

编辑: 为什么不尝试通过

列出表中的所有Cookie
SELECT id,name FROM moz_cookies;

看看是否有任何cookie? 如果您在列表中看到cookie,那么您的查询会出错,否则您可能会使用错误的sqlite文件。

尝试以下内容

select * from moz_cookies where name like "%name%";

答案 1 :(得分:4)

要在Firefox中设置Cookie,您必须在Firefox中查看网页。

您可能想要运行PHP server on local machine