- COOKIEJAR: it sets the cookie variables in the local machine and stores it in a file. we store it for later use. This file is written in netscap cookie file format. the values are delimited with a tab. A cookie is stored on a single line.
- COOKIEFILE: This variable sends the cookie file to the remote server.
see the following code block. it explains the above discussion.
//create cURL connection $curl_connection = curl_init('remote_server_url'); //set options curl_setopt($curl_connection, CURLOPT_POST, TRUE); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, false); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); //set data to be posted curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); curl_setopt($curl_connection, CURLOPT_COOKIEJAR, 'cookies.txt'); curl_setopt($curl_connection, CURLOPT_COOKIEFILE, 'cookies.txt');
Here we send the cookie with the last two lines.
Now if we redirect our header in the remote server, then there will be a problem. your server then could not find the cookie file. and you will be signed out or related problem will be arose.
To solve this problem, you need to set your cookie after redirect call is made. So, you need to set cookie like this after a redirection is made.
setcookie('asite', $site, time()+60*60, '/', 'site.com');
See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide
List of my works:
- Product Based Quantity Wise Shipping: Find it here.
- OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
- Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
- Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
- Custom Field Product - add unlimited custom fields to the product form: Find it here.
- Formcaptcha - add captcha on the register page: Find it here.