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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:43:05+00:00 2026-05-21T17:43:05+00:00

Here’s the situation: the user is able to sign into a MVC application from

  • 0

Here’s the situation: the user is able to sign into a MVC application from another website. That website is not ASP.NET-based. It could be PHP, JSP or Websphere… or anything

I have tried doing this:

 [HttpPost]
 public string RemoteLogOn(string userName, string password)
 {

     if (userName != null && password != null)
     {                  
          if (MembershipService.ValidateUser(userName, password))
          {
               FormsAuthentication.SetAuthCookie(userName, false);
               return "success";

          }
          else
          {
                return "failed";
          }                
      }
      else
      {
           return "failed";
      }    
}

Calling the MVC app at the /RemoteLogOn URI (posting the request using PHP and cURL) works. The “success” string is returned. However, it seems that the cookie is not generated properly – when I returned to the MVC site and check User. Identity.Name, null is returned.

What is the right way to allow user to log in via. a web service?

Edit How do I properly set the returned cookie.

PS. This is just a trial POC; eventually we’ll use SOAP or REST and try to improve the security.

Here’s the PHP code that did the calling

<?php
$url = "http://localhost:54134/Account/RemoteLogOn";
$fields = array(
            "userName" => "asd1234",
            "password" => "****"
        );

 foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string,'&');

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);

//execute post
$result = curl_exec($ch);

echo '<pre>'.print_r($result, true).'</pre>';

//close connection
curl_close($ch);
</php>

Debugging the app shows the user name and password are passed in properly to the MVC side.

  • 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-21T17:43:06+00:00Added an answer on May 21, 2026 at 5:43 pm

    OK what you need to do is save the cookie that comes back from your cURL request and make sure it gets sent with subsequent requests.

    This is how to set where to store cookies (and include in subsequent requests) in PHP:

    curl_setopt($ch, CURLOPT_COOKIEJAR, 'mycookiefile');
    

    You’ll need the cookie filename to be constant through the process, so I would suggest using a variable and initialising it thus:

    $cookieFile = tempnam("/tmp", "CURLCOOKIE");
    

    You can get more details on this at the PHP documentation site:

    http://www.php.net/manual/en/function.curl-setopt.php

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

Sidebar

Related Questions

Here's my scenario - I have an SSIS job that depends on another prior
Here's a query that works fine: SELECT rowid as msg_rowid, a, b, c FROM
Here's the flow that I am trying to achieve: 1) User uploads an audio
Here is another spoj problem that asks how to find the number of distinct
Here we can see that SVN is not adding files that need to be
Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes

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.