Ion Auth: How to display the current username in input form? |
[eluser]qpixo[/eluser]
I started using Ion Auth examples codes that comes with package and want to make a custom Login form. I'd like know how to keep and display the current username in this input form after user has clicked on 'Submit' button and validation message is wrong? Ex: In situation that he doesn't have a password correct I can't see to return any current input->post('username') I'm running on Mac with MAMP. Is there anything to do with _POST?
[eluser]rip_pit[/eluser]
Quote:when the login was un-successful, redirect the user back to the login page Because of the redirect, you will have to save the datas in a session or in a DB. The easiest way would be to save the username as a Flash variable (see Flash session) : it'll then be available once, in next page if login fails, save username using : Code: $this->session->set_flashdata('username', set_value('identity')); then at next load read it from flash session using : Code: $this->session->flashdata('username') More info : http://ellislab.com/codeigniter/user-gui...sions.html
[eluser]qpixo[/eluser]
@rip_pit Thanks a lot for your help! After I did the change it works great. The issue was really redirect() thing... I'd like to ask you, what is the difference between set_userdata() vs set_flashdata() for session. They seem doing the same task.
[eluser]qpixo[/eluser]
[quote author="gbd_dee" date="1335823639"]Im having the same issue[/quote] In case you need an example, here's the current code that works for me after the change: Code: public function login() {
[eluser]rip_pit[/eluser]
[quote author="qpixo" date="1335889770"]difference between set_userdata() vs set_flashdata() for session[/quote] the main difference is that flash data will be available only one time in your next page, then it will be auto cleared. Unlike Userdata that is a more classic session, the datas you save with it wont be destroyed unless you ask for it. Help says : Quote:CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared. These can be very useful, and are typically used for informational or status messages (for example: "record 2 deleted").
[eluser]qpixo[/eluser]
[quote author="rip_pit" date="1335892416"][quote author="qpixo" date="1335889770"]difference between set_userdata() vs set_flashdata() for session[/quote] the main difference is that flash data will be available only one time in your next page, then it will be auto cleared. Unlike Userdata that is a more classic session, the datas you save with it wont be destroyed unless you ask for it. Help says : Quote:CodeIgniter supports "flashdata", or session data that will only be available for the next server request, and are then automatically cleared. These can be very useful, and are typically used for informational or status messages (for example: "record 2 deleted").[/quote] Ok thanks for the explanation See the code that I posted above is it right way to do?
[eluser]rip_pit[/eluser]
[quote author="qpixo" date="1335901285"] Ok thanks for the explanation See the code that I posted above is it right way to do? [/quote] code seems fine as i tweaked my ion auth, i can't test it but it seems good. Does it work for you ?
[eluser]qpixo[/eluser]
[quote author="rip_pit" date="1335915334"][quote author="qpixo" date="1335901285"] Ok thanks for the explanation See the code that I posted above is it right way to do? [/quote] code seems fine as i tweaked my ion auth, i can't test it but it seems good. Does it work for you ?[/quote] Yes it works great!! I was just wonder if I could make it cleaner though...
[eluser]bill19[/eluser]
Hi Guys, I am using the Ion_Auth library, and I'm very new to forms, so if I may, I'd like to ask a basic question using the code you've already posted. when I run your public function login(), I get the following output: Quote:Login I'm getting the same error with my forms. What am I doing wrong? Thank you in advance, Bill |
Welcome Guest, Not a member yet? Register Sign In |