Possible Cookie Problem

Hi All

Before I trouble the help desk with this can someone tell me if a customer remains logged in on their return visit?



Everytime I return to the store I have to re login through authentication. Also the store doesn’t show the www in the browser address.



Thanks!

[quote name=‘ibaker’]Hi All

Before I trouble the help desk with this can someone tell me if a customer remains logged in on their return visit?



Everytime I return to the store I have to re login through authentication. Also the store doesn’t show the www in the browser address.[/QUOTE]Once the browser is closed, the cookie expires. The www is a subdomain. It is old school to show it and many websites elect not to show it anymore. To display it, you’ll need to edit your $cscart_http_host variable in config.php.

Great, thanks Larry!

[quote name=‘sculptingstudio’]Once the browser is closed, the cookie expires.[/QUOTE]Wow, I hadn’t noticed that. Surely you can change that expire setting? In my opinion you’re shooting yourself in the foot by clearing the cart, and as with this forum, ‘regulars’ will be irritated w/ being logged out each time they leave. I’d set a cookie to a few days minimum, and had planned to change my 30 day setting to 90 or longer when I switched over to CS.

[quote name=‘arlen’]Wow, I hadn’t noticed that. Surely you can change that expire setting? In my opinion you’re shooting yourself in the foot by clearing the cart, and as with this forum, ‘regulars’ will be irritated w/ being logged out each time they leave. I’d set a cookie to a few days minimum, and had planned to change my 30 day setting to 90 or longer when I switched over to CS.[/QUOTE]Hi Arlen,



You’re right about not keeping them logged on. And you should be able to change this. So I did some digging in the cookie code. Interesting. It seems the way it is now, subdomains could have a problem. Anyway, I added a function to keep the cookie for 30 days. To do this, add this function to core>fn_common.php:



```php //

// Set Cookie Function

//

function mySetCookie($cName, $cValue) { // cookie name with value of 0 will delete the cookie

$cookieExpire = time() + (60602430); // 30 day ($cookieExpire=0 will expire when browser closes)

$host = preg_replace(‘/^[Ww][Ww][Ww]./’, ‘’, preg_replace('/:[0-9]
$/', ‘’, $_SERVER[‘HTTP_HOST’]));

if (strcmp($cValue, “”) == 0) {

setcookie($cName, “”, 1, “/”, “.$host”, FALSE); // Delete

} else {

setcookie($cName, $cValue, $cookieExpire, “/”, “.$host”, FALSE);

$_COOKIE[$cName] = $cValue;

}

} ```



In core>currencies.php locate the code snippet and make it look like this:



```php if ($secondary_currency != @$_COOKIE[‘secondary_currency’.AREA]) {

setcookie(‘secondary_currency’.AREA, $secondary_currency, 0, ‘/’, false, 0);

mySetCookie('secondary_currency'.AREA, $secondary_currency);

} ```



In core>languages.php locate the code snippet and make it look like this:



```php if ($cart_language != @$_COOKIE[‘cart_language’.AREA]) {

setcookie(‘cart_language’.AREA, $cart_language, 0, ‘/’, false, 0);

mySetCookie('cart_language'.AREA, $cart_language);

} ```



In core>sessions.php locate the code snippet and make it look like this:



```php $current_host = defined(‘HTTPS’)? $cscart_https_host : $cscart_http_host;

setcookie($CSCART_SESSION_NAME, $GLOBALS[$CSCART_SESSION_NAME], TIME+SESSION_ALIVE_TIME, ‘/’, false, 0);

setcookie($CSCART_SESSION_NAME, $GLOBALS[$CSCART_SESSION_NAME], 0, ‘/’, false, 0);

mySetCookie($CSCART_SESSION_NAME, $GLOBALS[$CSCART_SESSION_NAME]);
sess_start();

} ```

Thanks a bunch Larry,



Would changing 30 to 90 take me to 90 days if I decided I wanted that? Seems logical, but my understanding of what you just did is limited (I do get time() + (secondsminuteshours*days) but most of the rest is over my head).



I’ve got to get a handle on PHP. I can see how OS software like CS-Cart offers you enormous flexibility because you understand what you are looking at and can mod as needed … really puts you in the driving seat. I feel like I’m running down the road a block or two behind you … hell, I’m probably still across town somewhere and just don’t realize it.

[quote name=‘arlen’]Thanks a bunch Larry,



Would changing 30 to 90 take me to 90 days if I decided I wanted that? Seems logical, but my understanding of what you just did is limited (I do get time() + (secondsminuteshours*days) but most of the rest is over my head).



I’ve got to get a handle on PHP. I can see how OS software like CS-Cart offers you enormous flexibility because you understand what you are looking at and can mod as needed … really puts you in the driving seat. I feel like I’m running down the road a block or two behind you … hell, I’m probably still across town somewhere and just don’t realize it.[/QUOTE]Once you play around with it a bit, you will get the hang of it. CS-Cart takes a little more time because of Smarty. Since I never used it before, it took about a day to figure it out and about two weeks for get a grip on all of CS-Cart.

I made the changes and it does not seem to work. Has anyone else been able to make it work?

come on… anyone???