# PHP Cookie Class

- Thread: https://externals.io/message/24129
- Original archive: https://news-web.php.net/php.internals/24129
- Started by Jason Boudreault on 2006-06-15T06:02:01+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #24129 — Jason Boudreault — 2006-06-15T06:02:01+00:00

URL: https://externals.io/message/24129#24129

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

---

## #24130 — Alexander Pak — 2006-06-15T07:13:24+00:00

URL: https://externals.io/message/24129#24130 · In reply to: #24129

I think it's a great idea, maybe it sould be implemented the same way for
sessions too?


>
> 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

---

## #24131 — M. Sokolewicz — 2006-06-15T16:15:09+00:00

URL: https://externals.io/message/24129#24131 · In reply to: #24130

Alexander Pak wrote:

> I think it's a great idea, maybe it sould be implemented the same way for
> sessions too?
> 
> 
> 
> > […]
> 
> 
> 

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.
