Setting A Cookie

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Setting A Cookie

Jamie Talbot
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I want to set a cookie dependent on whether a specific query var has been set.  ie, set the cookie
to be 'jamie' if author=jamie appears in the query.  As far as I can tell this can't be done at the
moment.  You can't send a cookie after the headers go out in send_headers().  But, you can't get at
the query_var until parse_request() has been called.  There doesn't seem to be an action in between
that would allow the cookie to be set.

Can anyone think of a way around this?  If not, a new action hook would be nice: 'pre_send_headers'
or 'post_parse_request'.  (That second one might be a little confusing).

Cheers,

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD4ke1rovxfShShFARAh/GAJ9trpF7UNtdZMWdG4FBzGkuxdlV7ACfYcCs
3qRKmVnUbmf593T2TCCw9Ns=
=Nf2P
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting A Cookie

David House
On 02/02/06, Jamie Talbot <[hidden email]> wrote:
> There doesn't seem to be an action in between
> that would allow the cookie to be set.

How about parse_query? wp-includes/classes.php:244

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting A Cookie

Andy Skelton
In reply to this post by Jamie Talbot
On 2/2/06, Jamie Talbot <[hidden email]> wrote:
> You can't send a cookie after the headers go out in send_headers().

You can't? I thought headers weren't actually sent until there was
output, which doesn't usually occur until after template_redirect. I'd
hook to that.

Andy
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting A Cookie

David House
On 02/02/06, Andy Skelton <[hidden email]> wrote:
> You can't? I thought headers weren't actually sent until there was
> output, which doesn't usually occur until after template_redirect. I'd
> hook to that.

I'd still go for parse_query. It's the earliest time after all the
query vars have been picked up and parsed. Personal preference I
guess.

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Setting A Cookie

Jamie Talbot
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David House wrote:
> On 02/02/06, Andy Skelton <[hidden email]> wrote:
>
>>You can't? I thought headers weren't actually sent until there was
>>output, which doesn't usually occur until after template_redirect. I'd
>>hook to that.

Thanks didn't know that.  I assumed they were sent in send_headers without checking.  (The name was
a distraction!)

> I'd still go for parse_query. It's the earliest time after all the
> query vars have been picked up and parsed. Personal preference I
> guess.

Had forgotten about the parse_query action.  Thanks, I'll give it a try.

Thanks both of you for your help!

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFD4qqrrovxfShShFARAv/GAKCCnR9Yj+uvBGzbeTyTnWaTbf43lwCcDD6I
KNuORegx900Oz8OvRn/H8Xs=
=q6WV
-----END PGP SIGNATURE-----
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...