PHP Cookie Class

php.internals

Jason Boudreault

20 years ago
So, I found myself wondering today why PHP has no built in way to treat cookies as objects. Why? I've already written my own class, but, we should implement this! $cookie = new Cookie(); if (!isset($cookie->username)) { $cookie->username = "george"; $cookie->save(); } ^^ is nice, I was also thinking, there should be an option to auto-save the cookies on __set :) -j

Alexander Pak

20 years ago
I think it's a great idea, maybe it sould be implemented the same way for sessions too? On 6/15/06, Jason Boudreault <jason@shaped.ca> wrote:
> > So, I found myself wondering today why PHP has no built in way to treat > cookies as objects. > > Why? > > I've already written my own class, but, we should implement this! > > $cookie = new Cookie(); > if (!isset($cookie->username)) { > $cookie->username = "george"; > $cookie->save(); > } > > ^^ is nice, I was also thinking, there should be an option to auto-save > the cookies on __set :) > > -j >
-- sincerely yours, Alexander Pak

M. Sokolewicz

20 years ago
Alexander Pak wrote:
> I think it's a great idea, maybe it sould be implemented the same way for > sessions too? > > On 6/15/06, Jason Boudreault <jason@shaped.ca> wrote: > >> >> So, I found myself wondering today why PHP has no built in way to treat >> cookies as objects. >> >> Why? >> >> I've already written my own class, but, we should implement this! >> >> $cookie = new Cookie(); >> if (!isset($cookie->username)) { >> $cookie->username = "george"; >> $cookie->save(); >> } >> >> ^^ is nice, I was also thinking, there should be an option to auto-save >> the cookies on __set :) >> >> -j >> > > >
I think it's a useless idea and (mainly) this discussion should be moved to php-generals (or can be reported as a feature suggestion in a bugreport; bugs.php.net). It has nothing to do with PHP internals.