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 6819837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:21:13+00:00 2026-05-26T21:21:13+00:00

So how can I check using codeigniter if the client is curl, and then

  • 0

So how can I check using codeigniter if the client is curl, and then return something different for it?

  • 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-26T21:21:14+00:00Added an answer on May 26, 2026 at 9:21 pm

    You can fake the user-agent when using cURL, so it’s pointless depending on the user-agent sent when you KNOW it’s a cURL request.

    For example: I recently wrote an app which gets the pagerank of a url from google. Now Google doesn’t like this, so it allows only a certain user agent to access its pagerank servers. Solution? Spoof the user-agent using cURL and Google will be none the wiser.

    Moral of the story: cURL user agents are JUST NOT reliable.

    If you still want to do this, then you should be able to get the passed user agent just like normal

    $userAgent=$_SERVER['HTTP_USER_AGENT'];
    

    EDIT A quick test proved this:

    dumpx.php:

    <?php
    
        $url="http://localhost/dump.php";
    
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL,$url);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        if($_GET['u']==y) {  
        curl_setopt($ch, CURLOPT_USERAGENT, "booyah!");
        }
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
        curl_setopt($ch, CURLOPT_TIMEOUT, 60);
        //curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'GET');
        curl_setopt ($ch, CURLOPT_HEADER, 0);
        $exec=curl_exec ($ch);
    ?>
    

    dump.php:

    <?php
        var_dump($_SERVER);
    ?>
    

    Case 1: http://localhost/dumpx.php?u=y

     'HTTP_USER_AGENT' => string 'booyah!' (length=7)
    

    Case 2: http://localhost/dumpx.php?u=n

    No $_SERVER[‘HTTP_USER_AGENT’]

    This proves that there is no default user agent for curl: it will just not pass it in the request header

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

Sidebar

Related Questions

Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can
i want to check 2 patterns using regex. can i check those both patterns
How can I check if an email folder exists using Zend_Mail_Storage_Imap, theres a createFOlder,
How can I check the given email id is valid or not using ELIPS
I am trying to execute DBCC CHECK DB('MyDB) using ADO.Net, but how can I
I'm using malloc to make an error check of whether memory can be allocated
I'm using this Jquery function for available username check. How can I fire this
I want something that can check if a string is SELECT , INSERT ,
Does anybody know how I can programmatically check (using C#) whether my program will
Can anyone advise what the best way to check (using .NET 3.5) if a

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.