Nov 22, 2009

Http Headers

free web hosting
Open Discussion & Free Web Hosting > Computers & Tech > Programming > Scripting > PHP

Http Headers

vizskywalker
I know you can use the header() function to send http headers. But I want to know if it is possible to simply echo them, like you can print them in perl. Also, is it possible to create a non-expiring cookie. Most sites that have a remember me option imply set the cookie to expire in a year or two, but it will eventually expire. Is it possible to create a cookie that never expires?

~Viz

Comment/Reply (w/o sign-up)

jipman
1. I think you're looking for a command called headers_list();

more info : http://nl2.php.net/manual/en/function.headers-list.php

2. for expiring issues. you could try to set the expiring variable to something like -10. If this doesn't work, maybe you should follow googles example and set the expiry date to 2038 wink.gif tongue.gif

Comment/Reply (w/o sign-up)

vizskywalker
Actually, I'm not looking for a function. In perl, you can simply print http headers like so:
CODE
print "Location: http://www.astahost.com\n";
print "Cookie: name = 'name', value = value\n";
print "Content-type: text/html\n\n";

The double newline character signals the end of the headers. I was wondering if using echo or print in php, the same thing was possible, because when I tried it, nothing happened, and I wondered if a special format was required, like maybe [code]echo httphead "Content-type: text/html\n\n";

And as for the expires, setting a negative expiration causes the cookie to be wiped immediately, it's a trick used by logout scripts. And i could set it to expire in one hundred years or so, but it will still expire. So that would be a no it isn't possible answer.

But thanks anyway.

~Viz

Comment/Reply (w/o sign-up)

vizskywalker
Due to vujsa beating over the head with common sense (and a reread of the php manual) I have concluded that the answer to my question is no. Basically I was trying to be able to write
CODE
header 'Location: http://www.astahost.com';
instead of
CODE
header('Location: http://www.astahost.com');
which cannot be done. Thanks anyway.

~Viz

Comment/Reply (w/o sign-up)


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

This textarea will convert to Rich-Text automatically (IE, Firefox, Chrome)


See Also,

*SIMILAR VIDEOS*
Searching Video's for http, headers
advertisement



Http Headers

Affordable Web Hosting, Low cost Web Hosting - ComputingHost.com