doulan8846 2012-02-13 15:24
浏览 47
已采纳

结束会话/清除cookie

Ok, so I've got some legacy code from another company that I have to maintain/repair. One of the features of this code is that there are several sites tied to this one main site, and whenever you navigate from the other sites to this site, a logo from the other site is displayed on the main site (basically this is a service for multiple banks to use, and each bank wants its own branding).

The problem is is that once you navigate from, say, site1 to main site, if you then navigate from site2 to main site, you'll still get site1's branding.

Is there a way to clear a session's cookies? So far they've got code like this, which should THEORETICALLY work:

    else
    {
        setcookie("cuid","",time() - 31536000); //DELETES COOKIE

        if( $cuid_demo!="samplecu" && $cuid!="samplecu" )
            setcookie("cuid",$cuid,time()+2592000); //2592000 = 1 month

        $link=dbconnect();

        if(!$link)
            die("error: Could not connect to database - ".dberror() );

        select_db($link) or die("error: ".dberror() );

        if (isset($admin_id))
        {
            $cuid = $admin_id;
            $id = $admin_id;
        }

        $query="UPDATE cusucceed SET visits=visits+1 WHERE id = '$cuid'";
        $result=dbquery($link, $query)or die("Database Server Error 2: ".dberror());
        include("index_main.php");

    } //END IF/ELSE TO CHECK FOR PREVIOUS VISIT WITH THE PAST MONTH
}

Before it does nothing. Shouldn't setcookie("cuid", "", time() - 31536000); delete the cookie, as the comments say?

  • 写回答

1条回答 默认 最新

  • dou44481 2012-02-13 15:28
    关注

    You need to set correct domain for cookie when you reset it.

    setcookie('name', NULL, -86400, 'cookie_path', 'subdomain.site1.com');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题