Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do my cookie be set or not in my firefox?

Lamp was installed on my local pc whose os is debian8 .
That is to say the client and server were all installed on my local pc.
The following code was saved as setcookie.php on my local pc.

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

<html>
<body>

</body>
</html>

Now php setcookie.php was executed on my local pc. The following codes were all executed on my local pc.

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";

Why there is no info selected for both of them ?
Do my cookie be set or not in my firefox? If it is set on my firefrox,why can't be selected in the sqlite statement?
In my opinion , the sql command select * from moz_cookies where name="Alex Porter"; will get such something as

name  user  value Alex Porter  expires 1515832198

Nothing display. Do as Aadil P. say the file was saved as setcookie.php in /var/www/html/tmp/setcookie.php. Executed 127.0.0.1/tmp/setcookie.php in firefox.
Open the Cookies with firebug.

enter image description here

The right result displayed here.
Two problem remains:
1.How many fields for the cookie?

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

There are only name,value,domain,raw size,path,expires,httponly,security in firebug cookies widow.
Why they are not the same?How many cookie elements on the related international standard?

2.How to write the proper sql command?

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

Both of them get nothing.

like image 340
showkey Avatar asked Jan 14 '16 08:01

showkey


2 Answers

You are using php setcookie.php to execute the php file via cli (as per your comment). Cookie or HTTP Cookie is stored in user's web browser.... [As per Wikipedia - https://en.wikipedia.org/wiki/HTTP_cookie]

You need to to open/execute this php file in a browser as mentioned by CL.

Since you have LAMP installed, move the script (php file) to a LAMP folder and open the page in browser by calling the file, your url address bar should look like http://localhost/setcookine.php(or http://127.0.0.1//setcookie.php) or something similar depending upon where the file is located.

Edit: Why don't you try listing all cookies for the table by simply

SELECT id,name FROM moz_cookies;

to see if there are any cookies at all? If you see the cookie in the list, then your query has an error, else you might be in the wrong sqlite file altogether.

Try the following as well

select * from moz_cookies where name like "%name%";
like image 69
Aadil P. Avatar answered Oct 17 '22 18:10

Aadil P.


To set a cookie in Firefox, you have to view the web page in Firefox.

You probably want to run a PHP server on local machine.

like image 20
CL. Avatar answered Oct 17 '22 19:10

CL.