We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Login from another app

Development and Programming

emagine media's avatar
emagine media
65 posts
15 years ago
emagine media's avatar emagine media

I have seen it posted in the forums before, but I have another piece of software I am trying to call EE for a login. The basic problem is that the other software (Social Engine 4) is the main element of the site, is quite well established and the client has tagged on an e-commerce shop at the end of a year of use. Simple answer, they don’t want ot change the site as it is, but they want the users of the SE4 to be able to login and trigger the EE shop I have running.

So what I did is this:

  1. Everything is on the same server/domain, SE4 is in the root and the EE install is in a lower /folder
  2. I have the EE 2.1 logmein plugin in place. This allows me to post a username or call the username from a segment (in my case 3). When I call this url in my browser, I am logged in with that user.
http://mydomain.com/folder/test/[email protected]

This works, if I change the username, it logs me in as the other person, verified by the username listed on the page, which changes per login. I have checked and it records the logins through the members panel as well. So all good so far.

  1. I decided that I could call the url using php curl, which seems like it will load the page. I echoed out everything and it all looks good, except no login is recorded, which is the problem.

My code for my EE test template is:

<html>
<head>
</head>
<body>

<?php print_r($_POST); ?>
Email: {post:email}
Login: {segment_2}

{!-- {exp:logmein:now email="{post:email}" expire="3600"} --}

{exp:logmein:now email="{segment_2}" expire="3600"}

{username}

{if segment_3 == 'logout'}
{exp:logmein:logout}
{/if}

</body>
</html>

Now I had php turned on to test this and I loaded my SE4 login. I also have global variables moule in to capture a post variable from curl. This is what I get for a return:

Array ( [email] => [email protected] [SUBMIT] => Send )
Email: [email protected] 
Login: [email protected] 
admin

Now the curl code I have in my other page is:

// call EE pages
      $ch = curl_init(); 
      $curlPost = 'email='  . urlencode($email) . '&SUBMIT=Send';    
      curl_setopt($ch, CURLOPT_URL, 'http://my.server.com/folder/index.php/test/'.$email);
      // Execute
      curl_setopt($ch, CURLOPT_POST, 0); 
      curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); 
      curl_exec($ch);
      die;

So anyone familiar with either the curl function and/or ee login sessions? I can’t figure out why the login is not being called, since everything is parsing out correctly. It’s like the EE install never sees the login being sent.

I have hammered it out this far, but baffled now at this point. I am sure it is something easy, so any help would be great.

       
David Dexter's avatar
David Dexter
88 posts
15 years ago
David Dexter's avatar David Dexter

Curl makes a remote call so you are not creating the login in the current session. I don’t think this approach will work. Opening your system to a login through the url is a VERY insecure method of login as well. I would strongly advise against it.

       
emagine media's avatar
emagine media
65 posts
15 years ago
emagine media's avatar emagine media

Yeah I am thinking this isn’t the best option for a variety of reasons. Thanks for the advice.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.