Welcome Guest, Not a member yet? Register   Sign In
cross side server login
#1

[eluser]gunprojects[/eluser]
Hi,
I wanna ask about cross server login,
for example i make a login page (http://url.com/homepage/login/) in domain a, and i wanna login in other domain, with an action to domain a, is there any solution about that.
what im asking is, how to submit a form using different domain, and redirect it if im using a login page in other domain in codeigniter, need a soulution.
#2

[eluser]Georgi Budinov[/eluser]
If the two domains are on the same machine and share same session store, you can authenticate the user on domain A, and then set the session id on domain B. This could be done for example like this: Setting A Cookie On A Remote Domain - The Basics. I haven't tested this exact solution but it is pretty clear - you output an img tag, and set its source to the remote domain url where your script is setting the session id cookie.
#3

[eluser]gunprojects[/eluser]
but it is not in the same machine, actually I make a programs in a wordpress, inside it, i wanna make a script that if i login, it will redirect to a CodeIgniter programs.
#4

[eluser]Georgi Budinov[/eluser]
Ok if you have control on the both domains, you can use the approach that I described earlier but you will have to make some modifications. You cn use the img tag and point to a script on the remote domain and give it parameters which user to log in and of course you will need some kind of encrypting mechanism with private and public key to make this more secure.
#5

[eluser]gunprojects[/eluser]
i have this code for example it redirect to my homepage but the user isn't login, it just only come to a welcome page, is this code enough to send a parameter to my login page
Code:
<form id="myForm" class="Homepage" action="http://url.com/testing/homepage/login/" method="post">
<table style="height: 68px;" border="0" cellspacing="0" cellpadding="0" width="235" align="center">
<tbody>
<tr>
<td>Username</td>
<td>&lt;input id="username" name="username" size="25" type="text" /&gt;&lt;/td>
</tr>
<tr>
<td>Password</td>
<td>&lt;input id="password" name="password" size="25" type="password" /&gt;&lt;/td>
</tr>
<tr>
<td></td>
<td>&lt;input type="submit" value="login" /&gt;&lt;/td>
</tr>
</tbody>
</table>
&lt;/form&gt;
#6

[eluser]Georgi Budinov[/eluser]
If http://url.com/testing/homepage/login/ is a valid controller function, you will have the username and the password in the $_POST variable.
#7

[eluser]gunprojects[/eluser]
yes it is a valid controller inside my controller, the id i used is the same as inside in the controller, but every time it send a parameter to it, it cannot access it.
#8

[eluser]Georgi Budinov[/eluser]
I am not sure I understand you right ...how do you pass the parameter ? Show more code ...
#9

[eluser]gunprojects[/eluser]
here is the code inside my controller
Code:
class Homepage extends MY_Controller {
  public function __construct() {
    parent::__construct();

    $this->load->library('form_validation');
    $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
  }
function login() {
    if(Current_User::user() === FALSE) {
      // set page title
      $this->data['title'] = 'testing Module - user login';
      // if after submit
      if($this->input->post('submit_login')) {
        // validate input before
        if($this->_login_validate()) {
          // login, if success, display admin homepage
          if(Current_User::login($this->input->post('username'), $this->input->post('password'))) {
            $this->session->set_userdata('group_id', Current_User::user()->group_id);
            Current_User::user()->last_login = date('Y-m-d H:i:s', time());
            Current_User::user()->save();
            redirect('dashboard');
          }
          $this->data['wrong'] = '<div class="error">Username or password is wrong</div>';
        }
      }
      $this->load_page('forms/login_form');
    } else {
      redirect('dashboard');
    }
  }
#10

[eluser]Georgi Budinov[/eluser]
I don't see $this->input->post('submit_login') in your form. The submit button don't have name attr.




Theme © iAndrew 2016 - Forum software by © MyBB