-- darren <[EMAIL PROTECTED]> wrote
(on Saturday, 05 April 2008, 10:51 PM -0500):
> Thanks guys.  As I had said, I had originally set the cookie with
> setcookie().  But, I kept getting an index error when I tried to
> access it.  That's why I thought I'd try the Zend_Http_Cookie class.
> After setting it with setcookie(), should I be able to access it in my
> init() or preDispatch() functions in my controllers?

You access cookies via $_COOKIE, even in ZF... but cookies you set
cannot be accessed in the same request that they are set, which may be
the issue you're having. 

> Thanks for the explanations.
> 
> 
> 
> On Sat, Apr 5, 2008 at 1:24 PM, Matthew Weier O'Phinney
> <[EMAIL PROTECTED]> wrote:
> > -- darren <[EMAIL PROTECTED]> wrote
> >  (on Saturday, 05 April 2008, 10:13 AM -0500):
> >
> > > Is there any reason why this would not be setting a cookie?  The code
> >  > doesn't generate any errors.  It just doesn't set a cookie.  If I put
> >  > in setcookie('name', 'value'), that will work.
> >  >
> >  > $cookie = md5($username . $id . "_somerandomstring_");
> >  > Zend_Loader::loadClass("Zend_Http_Client");
> >  > require_once "Zend/Http/Cookie.php";
> >  > $client = new Zend_Http_Client();
> >  > $cookie = new Zend_Http_Cookie('foo', $cookie, '.mydomain.com', time()
> >  > + 7200, '/path');
> >  > $client->setCookieJar();
> >  > $client->setCookie($cookie);
> >
> >  Zend_Http_Cookie is for use with Zend_Http_Client which is for making
> >  requests to *other* services -- not for setting cookies for a client
> >  browser. Use setcookie().
> >
> >
> >  > The code above raises a side question.  I don't want to get
> >  > sidetracked.  But, I guess I'll ask it now, what's the difference
> >  > between require_once and Zend_Loader::loadClass?
> >
> >  Zend_Loader::loadClass() allows you to pass a class name, and optionally
> >  a list of directories in which to look for the class file. Typically,
> >  require_once will be slightly faster... as long as the file is in your
> >  include_path.
> >
> >  --
> >  Matthew Weier O'Phinney
> >  Software Architect       | [EMAIL PROTECTED]
> >  Zend - The PHP Company   | http://www.zend.com/
> >
> 

-- 
Matthew Weier O'Phinney
Software Architect       | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to