1
I have this code that reads a file created by Netscape HTTP Cookie File, however I could only use the script and read the file of the user who is with the session username open, I need to list all the TXTS and read them all without exception.
NOTE: the files have different names:
<?php
require_once getcwd() . '/modules/config.php';
$username = null;
if (isset($_SESSION['username'])) {
$username = $_SESSION['username'];
}
$pointer = fopen(getcwd() . '/cookies/' . $username . '.txt', 'r');
while (!feof($pointer)) {
$row = fgets($pointer);
}
fclose($pointer);
How to read all files with different names other than the file with the name created in the session ?
EDITED
In the comments Anderson cited the use of function glob(), I was able to read all the files with this code.
foreach (glob(getcwd() . '/cookies/*.txt') as $file) {
$pointer = fopen($file, 'r');
while (!feof($pointer)) {
$row[] = fgets($pointer);
}
}
var_dump($row);
However it contains unnecessary lines in the file, I need to get only the cookies, look what comes back:
I just need the cookies, you know what I mean?

Read about the function
glob.– Woss
Ta blz. I’ll see.
– user89335
@Andersoncarloswoss can answer my own question?
– user89335
Yes, you can, no problem.
– Woss
@Andersoncarloswoss I edited, see if you can help me.
– user89335
Which of these lines would be cookies?
– Woss
_twitter_sess,ct0,auth_token,twid, dessses, prefix and values. understands?– user89335