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 8353733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:20:56+00:00 2026-06-09T09:20:56+00:00

I am using cookie helper in cakephp and i am using following code for

  • 0

I am using cookie helper in cakephp and i am using following code for accessing the value of cookie variable

$this->Cookie->write('testvar','testvalue');

I have made a helper class when i try to get the value of this cookie variable vid a following

$this->Cookie->read('testvar');

It produces an error(Call to a member function read() on a non-object).
Is there any other method by which i can access the cookie variable in helper.Although i can try the $_Cookie (server variable).

  • 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-09T09:20:58+00:00Added an answer on June 9, 2026 at 9:20 am

    Your helper should looks like:

    <?php
    App::uses('AppHelper', 'View/Helper');
    App::uses('CakeSession', 'Model/Datasource');
    class MyCookieHelper extends AppHelper 
    {
             public function writeCookie($name, $value = null) 
             {
                   return CakeSession::write($name, $value);
             }
             public function readCookie($name)
             {
                   return CakeSession::read($name);
             }
    }
    

    You can use it in your view like:

    $this->MyCookie->readCookie($cookie_var_name);
    

    Don’t forget to include MyCookie helper in your controller;

    public $components = array('MyCookie');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm setting a cookie using this code: setcookie(Blah,user,time()+86400); i'm then checking that cookie on
I have this code here: setcookie('visitcount',1+$_COOKIE['visitcount'],time()+60*60); $visitcount = $_COOKIE['visitcount']; print Number of views: .$visitcount;
im using jquery cookie to pass value of the element clicked on my first
I am using this copy directory helper addon for the directory helper to help
I'm using the jQuery cookie plugin to read/write/delete cookies. I'm using cookies to store
How can i store multiple values for a variable in cookie using php, for
I am creating cookie using jquery, please see below code: var divID = $(link).next(.open-block-holder).find(div:first).attr(id);
I have created a cookie using php and now I need to create a
I have recently been using cookie store and I want to transition to active
I'm using cookie plugin with jquery. I set cookie like $.cookie('key','value') . In firebug

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.