[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

header . socket and cookies

Posted on 2005-04-29
3
Medium Priority
?
175 Views
Last Modified: 2006-11-18
this is the function I found which to get header of URL.
But I don't know how to use IE-cookies in this.

function get_headers($url,$format=0)
   {
       $url_info=parse_url($url);
       $port = isset($url_info['port']) ? $url_info['port'] : 80;
       $fp=fsockopen($url_info['host'], $port, $errno, $errstr, 30);
       
       if($fp)
       {
           $head = "HEAD ".@$url_info['path']."?".@$url_info['query']." HTTP/1.0\r\nHost: ".@$url_info['host']."\r\n\r\n";            
           fputs($fp, $head);      
           while(!feof($fp))
           {
               if($header=trim(fgets($fp, 1024)))
               {
                   if($format == 1)
                   {
                       $key = array_shift(explode(':',$header));
                       // the first element is the http header type, such as HTTP 200 OK,
                       // it doesn't have a separate name, so we have to check for it.
                       if($key == $header)
                       {
                           $headers[] = $header;
                       }
                       else
                       {
                           $headers[$key]=substr($header,strlen($key)+2);
                       }
                       unset($key);
                   }
                   else
                   {
                       $headers[] = $header;
                   }
               }
           }
           return $headers;
       }
       else
       {
           return false;
       }
   }
0
Comment
Question by:ngocquynh85
  • 2
3 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 13894027
"But I don't know how to use IE-cookies in this.".

To do what exactly?

-r-
0
 

Author Comment

by:ngocquynh85
ID: 13894181
uhm, I want to use cookie when I get header.
first, I login into a website (by IE),
then I use this function to get header of one page in this site.
But it didn't work as I wish, because this function don't include cookie when I login a website.
:|
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 1000 total points
ID: 13894242
Have you got the advice already to look into the cUrl library?

see www.php.net/curl

-r-
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to implement server side field validation and display customized error messages to the client.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question