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

  • SEARCH
  • Home
  • 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 760067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:40:20+00:00 2026-05-14T15:40:20+00:00

I’m having an issue accessing raw request information from PHP when accessing a script

  • 0

I’m having an issue accessing raw request information from PHP when accessing a script using the HTTP DELETE directive. I’m using a JS front end which is accessing a script using Ajax. This script is actually part of a RESTful API which I am developing.

The endpoint in this example is:

http://api.site.com/session

This endpoint is used to generate an authentication token which can be used for subsequent API requests. Using the GET method on this URL along with a modified version of HTTP Basic Authentication will provide an access token for the client. This token must then be included in all other interactions with the service until it expires.

Once a token is generated, it is passed back to the client in a format specified by an ‘Accept’ header which the client sends the service; in this case ‘application/json’. Upon success it responds with an HTTP 200 Ok status code. Upon failure, it throws an exception using the HTTP 401 Authorization Required code.

Now, when you want to delete a session, or ‘log out’, you hit the same URL, but with the HTTP DELETE directive. To verify access to this endpoint, the client must prove they were previously authenticated by providing the token they want to terminate.

If they are ‘logged in’, the token and session are terminated and the service should respond with the HTTP 204 No Content status code, otherwise, they are greeted with the 401 exception again.

Now, the problem I’m having is with removing sessions. With the DELETE directive, using Ajax, I can’t seem to access any parameters I’ve set once the request hits the service. In this case, I’m looking for the parameter entitled ‘token’.

I look at the raw request headers using Firebug and I notice the ‘Content-Length’ header changes with the size of the token being sent. This is telling me that this data is indeed being sent to the server.

The question is, using PHP, how the hell to I access parameter information? It’s not a POST or GET request, so I can’t access it as you normally would in PHP. The parameters are within the content portion of the request.

I’ve tried looking in $_SERVER, but that shows me limited amount of headers. I tried ‘apache_request_headers()’, which gives me more detailed information, but still, only for headers. I even tried ‘file_get_contents(‘php://stdin’);’ and I get nothing.

How can I access the content portion of a raw HTTP request?

Sorry for the lengthy post, but I figured too much information is better than too little. 🙂

  • 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-14T15:40:20+00:00Added an answer on May 14, 2026 at 3:40 pm

    I think you’re misusing HTTP DELETE. It should normally be used as a request to delete a resource on the server: the resource pointed to by the request URI. You could encode your access token as a query parameter, but that’s not how DELETE should be used. e.g, a request of:

    DELETE /somescript.php?token=XYZ123
    

    SHOULD be treated as a request to delete the ‘somescript.php’ file from the server.

    You should rewrite your system to use a POST request, which is the usual method of doing such things. The POST handler script can delete the session and reply with the appropriate headers to unset any cookies you might have created.

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

Sidebar

Ask A Question

Stats

  • Questions 431k
  • Answers 431k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer ok, got a step closer by using inputs.bind("autocompleteselect", setupRow); now… May 15, 2026 at 2:20 pm
  • Editorial Team
    Editorial Team added an answer I would use the functions instead of the constants, but… May 15, 2026 at 2:20 pm
  • Editorial Team
    Editorial Team added an answer For v3 it is under Configuration->Logger Settings. (You may also… May 15, 2026 at 2:20 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.