Welcome Guest, Not a member yet? Register   Sign In
flexi auth - A user authentication library for CodeIgniter
#66

[eluser]haseydesign[/eluser]
@code_has_been_ignited

Hey man,

Regarding how to return error messages with actions like failed logins, you can use the 'get_messages()' function.

How you implement the passing of data returned from this function to your view is up to you.
You could simply call the function directly within you view if you wanted.

What I will note though is that if like in the demo you add the returned messages to a CI flash session, then the page must be reloaded before the message will be available from the flash session data - this is just how CI's session class works.

So as an example for returning error messages using CI flash sessions after a login attempt, you could use the following code:
Code:
// Attempt to login user.
$this->flexi_auth->login('login_identity', 'login_password');

// Add message to CI flash data.
$this->session->set_flashdata('message', $this->flexi_auth->get_messages());

// Ensure the page is reloaded to make the flashdata available on the next page.
redirect('auth');

To return the message instantly:
Code:
// Attempt to login user.
$this->flexi_auth->login('login_identity', 'login_password');

// Echo the message.
echo $this->flexi_auth->get_messages();


Messages In This Thread
flexi auth - A user authentication library for CodeIgniter - by El Forum - 10-17-2012, 04:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB