use App\Models\User;
use Cubist\Util\Files\Files;
+use Cubist\Util\Str;
use Cubist\Util\Zip;
use Exception;
use GuzzleHttp\Client;
public function __construct($user)
{
$this->user = $user;
- $this->_cookies = new FileCookieJar(Files::mkdir(protected_path('ws2cookies/')) . $this->user->id, true);
+ if (null !== $this->user) {
+ $cookie_id = $this->user->id;
+ } else {
+ $cookie_id = Str::random(5);
+ }
+ $this->_cookies = new FileCookieJar(Files::mkdir(protected_path('ws2cookies/')) . $cookie_id, true);
$this->_http = new Client(['base_uri' => $this->_domain, 'timeout' => 60000, 'read_timeout' => 60000, 'cookies' => $this->_cookies]);
}