homepage Welcome to WebmasterWorld Guest from 54.227.25.58
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP Server Variables
Are these available PHP $_SERVER variables
MickeyRoush




msg:4467433
 12:52 am on Jun 20, 2012 (gmt 0)

Ok, first off I'm a noob when it comes to PHP.

I'm just trying to find out if these are available server variables to PHP.

I've seen this link here:
[php.net...]

and I was wondering if most of the server variables in mod_rewrite were also available.
[httpd.apache.org...]

Two especially.

1. THE_REQUEST
2. HTTP_COOKIE

So for PHP:
1. $_SERVER['THE_REQUEST']
2. $_SERVER['HTTP_COOKIE']

I've seen $_SERVER['HTTP_COOKIE'] being used, so I was wondering if $_SERVER['THE_REQUEST'] could be used. These are for a security script that I'm working on.

Any suggestions would be greatly appreciated.

 

SteveWh




msg:4467632
 2:44 pm on Jun 20, 2012 (gmt 0)

When I run phpinfo(), I see an entry for _SERVER["HTTP_COOKIE"], so it exists. _SERVER['THE_REQUEST'] is not there, but it looks like you could replicate it manually using something like this:

$_SERVER["REQUEST_METHOD"] . " " .
$_SERVER["REQUEST_URI"] . " " .
$_SERVER["SERVER_PROTOCOL"]

It appears there are also equivalent values in the array of $_ENV[] variables.

Depending on how you want to see the cookie data, you might find the $_COOKIE[] array useful.

rocknbil




msg:4467660
 4:45 pm on Jun 20, 2012 (gmt 0)

Environment variables are available to any server site language; they come from the underlying server software, where it's 'nix, windows, or whatever-based.

PHP:
$_SERVER['THE_REQUEST']
$_SERVER['HTTP_COOKIE']

Perl

$ENV{'THE_REQUEST'}
$ENV{'HTTP_COOKIE'}

ASP/.NET
Request.ServerVariables("THE_REQUEST")
Request.ServerVariables("HTTP_COOKIE")

in a mod_rewrite/.htaccess context:

%{THE_REQUEST}
%{HTTP_COOKIE}

AFAIK HTTP_COOKIE will **only** be available if a cookie (or cookies) has been set for the domain you're currently on. Sometimes this cookie is set by server software, whether you're doing it in your programming or not, and can be a session or persistent cookie. It's your job to loop through all the cookies in it and identify them by name (key). :-)

MickeyRoush




msg:4467839
 4:07 am on Jun 21, 2012 (gmt 0)

Thanks for the replies. @rocknbil, you answered my question exactly. Thanks again.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved