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

  • Home
  • SEARCH
  • 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 6390735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:35:05+00:00 2026-05-25T03:35:05+00:00

I have been trying like this – // ================ // = set a Cookie

  • 0

I have been trying like this –

 // ================
// = set a Cookie for the users city =
// ================
function set($cityId = null){

    $this->components[] = 'RequestHandler';

    $this->components[] = 'Cookie';
    $this->Cookie->name = 'Exampleoffers';  
    //$this->Cookie->time =  3600;  // or '1 hour' 
    //$this->Cookie->path = '/bakers/preferences/';   
    $this->Cookie->domain = 'www.example.co.uk';     
    $this->Cookie->secure = false;  
    $this->Cookie->key = 'kkjdDqSI232qs*&sXOw!';

    $cities = ($this->City->find('list'));  

    if($cities[$cityId]) {
        $this->Cookie->write ("Deal.city_id", (int) $cityId, false, "+2 months");

    } else {
        $this->Cookie->write ("Deal.city_id", key($cities), false, "+2 months");

    }

however, I am not sure if it is clashing with my Authsome cookie (?) or something else, but I am unable to read this value back.

Is there some way to specify which cookie you want to read() from in CakePHP?

Is there a way to have a cookie with 2 diffferent values of expiry times? – i.e. a cookie has User.id with a expiry of 1 week, and a Deal.city_id with a expiry of 2 months, say? Or am I right to think I DO need 2 cookies?

many thanks for any tips. It’s cake 1.3 btw !

  • 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-05-25T03:35:05+00:00Added an answer on May 25, 2026 at 3:35 am

    You can, remember cookies are saved on the system so if you only save the cookie one time on that system it will have the set values, however, you cannot have 2 cookies with the same name set, which means that when you go and save the cookies you’ll have to do this:

    $this->Cookie->write('Name1', $data, false, $time);
    
    $this->Cookie->write('Name2', $data, false, $time);
    

    If you don’t, one will overwrite the other.

    EDIT: Adding some links in case you have more doubts:

    API page of CookieComponent: http://api13.cakephp.org/class/cookie-component

    Cookbook page of CookieComponent: http://book.cakephp.org/view/1280/Cookies

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

Sidebar

Related Questions

I have been trying to convert sdot like this html_entity_decode(⋅); Any tips?
I have been trying to create a code like this: If you show 'us.gif'
I have been trying to make a simple app with 3 fields like this:
Hi I have been trying to pepopulate a textareafield using something like this in
I have been trying to install ReviewBoard and all looks like it has gone
I have been trying to get around this error for a day now and
I have been trying to call a C function that has the following signature
I have been trying to solve this bug for 2 days straight and can't
I have been trying to set up a PHP based SOAP client to connect
Hi i have been trying this for hours upon hours, this forum is my

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.