Skip to content

Commit c5baee2

Browse files
committed
Improved cookie jar file location
1 parent 54f4acb commit c5baee2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

examples/client_auth.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<?php
22
require "../lib/php_crud_api_transform.php";
33

4+
$cookiejar = tempnam(sys_get_temp_dir(), 'cookiejar-');
5+
46
function call($method, $url, $data = false) {
7+
global $cookiejar;
58
$ch = curl_init();
69
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
710
curl_setopt($ch, CURLOPT_URL, $url);
@@ -14,8 +17,8 @@ function call($method, $url, $data = false) {
1417
}
1518
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1619

17-
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/cookies.txt');
18-
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/cookies.txt');
20+
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiejar);
21+
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiejar);
1922

2023
return curl_exec($ch);
2124
}

0 commit comments

Comments
 (0)