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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:38:17+00:00 2026-06-06T20:38:17+00:00

I am trying to log into a website, then go to a link and

  • 0

I am trying to log into a website, then go to a link and then submit a form to get the desired data. I want to do it using cURL. I have achieved success in loggin into the website. The login redirects me to the profile page.

Now I need to follow a link and then submit a form! but when i do that using CURL the session is invalidated. I get the JSESSIONID in a cookie.txt file i used to store the cookie created. All the examples i have seen are just about loggin into a website or just a registration form submission.that is just one single POST request!

How do I go to another link and then submit another form using curl after I have successfully logged in and stored the cookie?

I am using WAMP as my local server.

<?php
$username="myusername"; 
$password="mypassword"; 
$url="http://onlinelic.in/LICEPS/Login/webLogin.do";
$referer = "http://onlinelic.in/epslogin.htm"; 
$postdata = "portlet_5_6{actionForm.userName}=".$username."&portlet_5_6{actionForm.password}=".$password;
$cookie = "cookie.txt" ;
$ch = curl_init(); 
curl_setopt ($ch, CURLOPT_URL, $url); 
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0");
curl_setopt($ch,CURLOPT_COOKIESESSION,false); 
curl_setopt ($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); 
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt ($ch, CURLOPT_REFERER, $referer);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt ($ch, CURLOPT_POST, 1); 
$result = curl_exec ($ch);
logIntoLocator(); 
curl_close($ch);

function logIntoLocator()
{
    $pincode = "731234";
    $locatorType = "P";
    $url = "http://onlinelic.in/LICEPS/appmanager/Customer/CustomerHome?_nfpb=true&_windowLabel=Cust_Agent_Locator_portlet_25_2&Cust_Agent_Locator_portlet_25_2_actionOverride=%2Fportlets%2Fvisitor%2FAgentLocator%2Flocating";
    $referer = "https://customer.onlinelic.in/LICEPS/appmanager/Customer/CustomerHome?_nfpb=true&_windowLabel=CustomerLocatorsPortlet_1&_cuid=RC_t_832059&_pagechange=AgentLocator";
    $postData = "Cust_Agent_Locator_portlet_25_2wlw-radio_button_group_key:{actionForm.agentRadioOption}=".$locatorType."&Cust_Agent_Locator_portlet_25_2{actionForm.agentOption}=".$pincode;
    $cookie = "cookie.txt" ;
    $agentCurl = curl_init();
    curl_setopt ($agentCurl, CURLOPT_URL, $referer); 
    curl_setopt ($agentCurl, CURLOPT_SSL_VERIFYPEER, true);
    curl_setopt ($agentCurl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0");
    curl_setopt($agentCurl,CURLOPT_COOKIESESSION,true);
    curl_setopt ($agentCurl, CURLOPT_TIMEOUT, 60); 
    curl_setopt ($agentCurl, CURLOPT_FOLLOWLOCATION, 1); 
    curl_setopt ($agentCurl, CURLOPT_RETURNTRANSFER, 1);  
    curl_setopt ($agentCurl, CURLOPT_REFERER, $referer);
    curl_setopt ($agentCurl, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt ($agentCurl, CURLOPT_COOKIEFILE, $cookie);
    curl_setopt ($agentCurl, CURLOPT_POSTFIELDS, $postData);
    curl_setopt ($agentCurl, CURLOPT_POST, 1); 
    $result = curl_exec ($agentCurl);    
    echo $result;   
}

If you like to give it a try the username is “manashch1” and the password is “nokia1105*”. login there and go the AgentLocator and there u can enter pincode as 731234 and get the data needed.

  • 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-06T20:38:18+00:00Added an answer on June 6, 2026 at 8:38 pm

    You need to attach the cookie(s) to CURL. There are two options:

    1. You can do this all manually by reading the cookie, and attaching manually using

      $ch = curl_init();
      $sCookie = 'JSESSIONID=' . $sessionIDSavedEarlier . '; path=/'; 
      curl_setopt ( $ch , CURLOPT_COOKIE, sCookie );
      ... rest of POST
      
    2. You can use a “cookie jar” (probably easiest)

      $ch = curl_init();
      curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
      curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
      ... rest of POST
      

    (Making sure you can read/write to a file called “cookie.txt” – if you have multiple users using hte script, then make that file unique for each user through a PHP session!)

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

Sidebar

Related Questions

I'm trying to create a script to log into a JSP website using LWP
I am trying to use PHP and cURL to log in to a website
I am trying to log into google reader using AfNetworking AfHttpClient but I am
I am trying to log into facebook here is my code: <body> <form id=form1
I'm trying to lean PhantomJS. I need to log into a website, and perform
I am trying to log in to my website (www.trailbehind.com) and then send a
I'm trying to build an android app that will log into a website, scrape
Evening! I'm trying to log in into a website with zombie.js, but I don't
I'm trying to use HtmlUnit in Java to log into a website. First i
I am trying to use PowerShell to log into a website and download 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.