Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] How to get the USERNAME from registration in the tpl_general_message file
#1

(This post was last modified: 10-24-2015, 09:13 PM by IeMdev. Edit Reason: Mark as solved )

Hi,
I have an application based on Codeigniter 3, however, the controllers are encrypted with ironcube.

For integration reasons with another app I need to get and store in a session var the 'username' that is submitted when a new account is registered and use this value in the tpl_general_message file that loads with the congratulations message.

In V2 of Codeigniter was was able to achieve this by simply adding to the Form Helper file:
Code:
if(isset($_POST['username'])){
$_SESSION['jamUsername'] = $_POST['username'];
}

However, it does not seem to be working with V3 so now things are broken. There is no value for $_POST['username'] at this point of the process.

Any better ways of getting this value?

Thanks
Reply
#2

(10-23-2015, 04:11 AM)IeMdev Wrote: Hi,
I have an application based on Codeigniter 3, however, the controllers are encrypted with ironcube.

For integration reasons with another app I need to get and store in a session var the 'username' that is submitted when a new account is registered and use this value in the tpl_general_message file that loads with the congratulations message.

In V2 of Codeigniter was was able to achieve this by simply adding to the Form Helper file:

Code:
if(isset($_POST['username'])){
    $_SESSION['jamUsername'] = $_POST['username'];
}

However, it does not seem to be working with V3 so now things are broken. There is no value for $_POST['username'] at this point of the process.

Any better ways of getting this value?

Thanks

You modified system form_helper file?

I think the correct way to do this is the following:

At controller that you use to auntenticate for example Auth at login action you can make the following (assuming you have to check the username and password and have a model for it):


PHP Code:
if ($this->input->post('username') && $this->input->post('password')) {
  if($this->auth_model->checkUser($this->input->post('username'), $this->input->post('password'))) {
    $this->session->set_userdata('jamUsename'$this->input->post('username'));
  }

Greetings.
Reply
#3

Thanks for the very quick response rtorralba.

However, I can not do this because all of the controllers are encrypted using iconcube. Using the helper file was a hack as if is not encrypted.

I've just come up with another idea and that is to add the session var setting to the config file as the controllers would all load this file. Not sure if that will work and no doubt there are much better ideas on how to achieve this.
Reply
#4

(This post was last modified: 10-24-2015, 09:12 PM by IeMdev. Edit Reason: used wrong code block )

I've solved the issue by adding the set session var as follows

Code:
if(isset($_POST['username'])){
   $_SESSION['jamUsername'] = $_POST['username'];
}

nto the cofig file.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB