Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:30:50+00:00 2026-06-17T09:30:50+00:00

I have this function to set a cookie: private function setCookie($key, $value){ if(setcookie( $key,

  • 0

I have this function to set a cookie:

private function setCookie($key, $value){
        if(setcookie(
            $key,
            $this->encrypt($value),
            time() + 2592000,
            adminpath,
            database::getDomain(),
            database::getHTTPS(),
            true
        )){ // set cookie for a month
            return true;
        }
        else{ // cookie could not be created, write to errorlog
             $error  = array(
                "type"      => "other",
                "argument"  => 1,
                "class"     => __CLASS__,
                "function"  => __FUNCTION__,
                "errorMsg"  => "Could not create cookie ".$key." with value ".$value,
                "file"      => __FILE__,
                "line"      => __LINE__
            );
            $this->errorlog->log($error);
            return false;
        }
    }

Then I use this code to unset the cookie:

private function destroyCookie($key){
        if(setcookie(
            $key,
            " ",
            time() - (time() + 2592000), 
            adminpath,
            database::getDomain(),
            database::getHTTPS(),
            true
        )){
            return true;
        }
        else{
            $error  = array(
                "type"      => "other",
                "argument"  => 1,
                "class"     => __CLASS__,
                "function"  => __FUNCTION__,
                "errorMsg"  => "Could not destroy cookie ".$key,
                "file"      => __FILE__,
                "line"      => __LINE__
            );
            $this->errorlog->log($error);
            return false;
        }
    }

I’m probably missing something very simple, but I can’t figure out why my cookie isn’t deleted.
Both functions are in the same class and the function database::getDomain() results in “www.creetab.com” and the function database::getHTTPS() results in “false”. adminpath is “/admin/”.
Could someone please help me fix this problem?
Setting the cookie works fine, it’s just deleting the cookie that doesn’t work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:30:51+00:00Added an answer on June 17, 2026 at 9:30 am
    $key,
    " ",
    time() - (time() + 2592000), 
    

    should be:

    $key,
    "",
    time() - 2592000, 
    

    Otherwise you are just giving it a value of an empty space, which is still a value. You want to give it no value at all, by making it empty. Also set the expiration time as above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function which is supposed to set a certain time format to
I use this function to set a cookie for the entire domain name: setcookie(tuittingID,
I have got two pages. example.com/php.com and example.com. I use this function to set
I have click events set up like this: $('.dialogLink') .click(function () { dialog(this); return
I have this bit of code where I try to set a cookie using
I am new to zend framework. I have write this code to set cookie
To counteract magic quotes I have this function set at the top of every
Possible Duplicate: How to set/unset cookie with jQuery? So I have this extremely simple
so i have this problem, i'm using a index.inc.php file to set a cookie
I have been trying like this - // ================ // = set a Cookie

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.