TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   General (http://www.talkphp.com/general/)
-   -   Problem updating Cookie on live host (http://www.talkphp.com/general/6078-problem-updating-cookie-live-host.html)

Kingdom 01-03-2012 03:22 AM

Problem updating Cookie on live host
 
This works fine on localhost, but the same code just won't update my live website cookie. Here's the code:

index.php
PHP Code:

    $lg->updateCookies($username$hashSalt[0]); 

updateCookies function:
PHP Code:

    $site '.ciadacapa.com.br'

    
// ---------------------------------------------------
    // Updates the cookies
    // ---------------------------------------------------
    
function updateCookies($username$hash){
        
setcookie('ciadacapaUser'''time()-3600'/'$this->site);
        
setcookie('ciadacapaHash'''time()-3600'/'$this->site);
        
setcookie('ciadacapaUser'$usernametime()+3600*24*7'/'$this->site);
        
setcookie('ciadacapaHash'$hashtime()+3600*24*7'/'$this->site);
        
        return 
true;
    } 

Although the class is receiving the correct values, the cookie just retains the old value it had and never updates. Any ideas on this? :-/

Thanks in advance!

wGEric 01-05-2012 10:11 PM

This script works for me

PHP Code:

setcookie('TESTCOOKIE'''time()-3600);
setcookie('TESTCOOKIE''value' rand(1,20), time()+3600); 

So I would assume yours would work as well. I tested that using Firefox 9.

When you set a cookie it sends the following in the headers

Code:

Set-Cookie: TESTCOOKIE=deleted; expires=Wed, 05-Jan-2011 22:09:38 GMT
TESTCOOKIE=value11; expires=Thu, 05-Jan-2012 23:09:39 GMT

So I wonder if the browser is getting confused with setting the same cookie twice. I don't know though. This is all speculation.


All times are GMT. The time now is 02:26 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0