Skip to content

Commit 91c0c47

Browse files
committed
Client: setCookieStorage: initial impl
1 parent 264eb8f commit 91c0c47

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/DatingVIP/API/Client.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ class Client
4747
*/
4848
protected $timeout = 5;
4949

50+
/**
51+
* Cookie storage path
52+
*
53+
* @var int $cookie [= false]
54+
* @access protected
55+
*/
56+
protected $cookie = false;
57+
5058
/**
5159
* Instance of DatingVIP\cURL\Request lib.
5260
*
@@ -100,6 +108,20 @@ public function setTimeout($timeout)
100108
: $this->timeout = $timeout;
101109
}
102110

111+
/**
112+
* Set cookie storage file
113+
*
114+
* @param string $file
115+
* @access public
116+
* @return bool
117+
*/
118+
public function setCookieStorage($file)
119+
{
120+
$this->cookie = (string) $file;
121+
122+
return !empty($this->cookie);
123+
}
124+
103125
/**
104126
* Execute API command.
105127
*
@@ -157,6 +179,10 @@ private function curl()
157179
$this->curl->setCredentials($this->user, $this->pass);
158180
}
159181

182+
if ($this->cookie && is_writeable(dirname($this->cookie))) {
183+
$this->curl->setCookieStorage($this->cookie);
184+
}
185+
160186
return $this->curl->setTimeout($this->timeout);
161187
}
162188

0 commit comments

Comments
 (0)