Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6950267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:04:18+00:00 2026-05-27T14:04:18+00:00

I have a question: If I set cURL to include header information in the

  • 0

I have a question:

If I set cURL to include header information in the output, how do I extract just the PHPSESSID information from that output?

The output looks something like that:

OUTPUT: HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Wed, 26 Sep 2011 19:10:48 GMT    Server: Apache/2.2.16 (Win32) mod_ssl/2.2.16 OpenSSL/0.9.8o X-Powered-By: PHP/5.3.5 Set-Cookie: PHPSESSID=lsa18d8r126ps1vfp4h05dh8r4; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache     Transfer-Encoding: chunked Content-Type: text/html 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:04:19+00:00Added an answer on May 27, 2026 at 2:04 pm

    This is a very simple solution, I don’t know if there is any curl way to retrieve that, but it can be handled with a simple regexp.

    $foo="HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Wed, 26 Sep 2011 19:10:48 GMT    Server: Apache/2.2.16 (Win32) mod_ssl/2.2.16 OpenSSL/0.9.8o X-Powered-By: PHP/5.3.5 Set-Cookie: PHPSESSID=lsa18d8r126ps1vfp4h05dh8r4; path=/ Expires: Thu,19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache     Transfer-Encoding: chunked Content-Type: text/html";
    
    echo preg_replace("/.*PHPSESSID=([^;]*);.*/", "\\1", $foo);
    

    If the string is syntactically the same for every request you can do it as shown.
    The “;” which marks the end of the session id is mandatory, else the regexp fails and returns the whole string, because it did not match. Maybe you should use a preg_match in front of a extraction to make sure it is syntactically correct or even there exists a PHPSESSID in the string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is for experiences programmers. Do you have a set process that you
I am creating a survey form that needs to have each question and set
I have this question in my text book: Suppose that we have a set
I think I have question that looks similar to many old questions but it
I have one question about sys.setrecursionlimit() From the python docs this function: Set the
I have a question about how to set up the relations between two models
I have a Question class: class Question { public int QuestionNumber { get; set;
i have a question about using GalleryView. At first, i set five default images
I have to set GridView.DataKeyNames (This is really a question about the syntax for
I have a SVNSERVE server set up to host multiple repositories. Short question here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.