public function createCookieDir($credentials)
{
if (!isset($credentials["cookiesDir"])) {
$credentials["cookiesDir"] = "Oara";
}
if (!isset($credentials["cookiesSubDir"])) {
$credentials["cookiesSubDir"] = "Import";
}
if (!isset($credentials["cookieName"])) {
$credentials["cookieName"] = "default";
}
$dir = COOKIES_BASE_DIR . DIRECTORY_SEPARATOR . $credentials['cookiesDir'] . DIRECTORY_SEPARATOR . $credentials['cookiesSubDir'] . DIRECTORY_SEPARATOR;
if (!is_dir($dir)) {
if (!mkdir($dir, 0777, true)) {
throw new \Exception('Problem creating folder in Access');
}
}
// Deleting the last cookie
if ($handle = \opendir($dir)) {
/* This is the correct way to loop over the directory. */
while (false !== ($file = \readdir($handle))) {
if ($credentials['cookieName'] == \strstr($file, '_', true)) {
\unlink($dir . $file);
break;
}
}
\closedir($handle);
}
$cookieName = $credentials["cookieName"];
$cookies = $dir . $cookieName . '_cookies.txt';
$this->_cookiePath = $cookies;
}