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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:22:41+00:00 2026-06-09T08:22:41+00:00

$cookie=cookie.txt; $data = array(); $data[‘global_id’] = raj; $data[‘global_password’] = raj; foreach ($data as $key

  • 0
$cookie="cookie.txt"; 
$data = array();
$data['global_id'] = "raj";
$data['global_password'] = "raj";

foreach ($data as $key => $value){
    $post_items[] = $key . '=' . $value;
}

//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);


$curl_connection = curl_init('http://somedomain.com/cgi-bin/login.pl');
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, 0);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl_connection, CURLOPT_REFERER, 'http://somedomain.com/cgi-bin/login.pl');
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($curl_connection, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($curl_connection, CURL_COOKIEFILE, '');
$result = curl_exec($curl_connection);

if($result == "success"){
    header("Location: http://somedomain.com/cgi-bin/index.pl");
}
else{
    echo "Login failed";
}

//close the connection
curl_close($curl_connection);

Whats wrong with it… I cant login

After executing this script if I goto http://somedomain.com/cgi-bin/index.pl it should logged in . How can I do this ?

  • 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-06-09T08:22:43+00:00Added an answer on June 9, 2026 at 8:22 am

    You should set CURLOPT_RETURNTRANSFER to true. Probably your $result is empty.

    Moreover while setting CURLOPT_REFERER you obviously used the wrong variable. ($ch)

    EDIT:

    It seems as if the following line is missing:

    curl_setopt($curl_connection, CURLOPT_POST, true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function cookiesToSession() { foreach($_COOKIE as $key => $value) { $_SESSION[$key] = $value; } }
I'm setting the curl cookiejar option with the following: curl_setopt($ch, CURLOPT_COOKIEFILE, cookie.txt); this puts
I can retrieve a Cookie value by: <?php $cookie=$_COOKIE[cookieName]; ?> Now i want to
string line; ifstream myfile (aaa.txt); getline (myfile,line); system(curl.exe -b cookie.txt -d test=+line+ http://example.com );
How can I port this wget stuff to scala: wget --keep-session-cookies --save-cookies cookies.txt --post-data
I created cookie with server side code (c#) and it was shown in chrome
I am setting a cookie, but having some issue. Currently the cookie format is
I got this cookie returned from web-server in Set-Cookie header: PHPSESSID=462rutd8g0sbg9sinh3hqa2ol6; path=/,wordpress_test_cookie=WP+Cookie+check; path=/,wordpress_ca07030412dd7fcd4dbeaae0bd9f5df9=testemail@example.com; expires=Sun,
With the new Cookie regulation, like all of us I need to display a
Suppose I created a cookie with one year expiration in domain abc.com and now

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.