1

How to pass variable between two functions in same controller?

Do I need to use $this->session->set_flashdata is this right way to go ?

function load() {
    $this->userhash = $this->uri->segment(3);
}

function save() {
    $query_customer = $this->Customers->get_customer($this->userhash);
}

sorry if this is a basic stuff, but I am still learning.

I need to edit my question

In Ivan link, that I also googled out

there is a code which goes something like this

function index() {
    $this->msg = 'data';
    $this->testme();
}

function testme() {
    echo $this->msg;
}

and its works, but I can not call $this->testme() directly in index(), so I can not load save() in load()

1 Answer 1

2

Passing data between two functions in my controller class

Sign up to request clarification or add additional context in comments.

2 Comments

I also google this out, but here he is calling $this->index(); again in function, I can not do that. I just tried to use $this->session->set_flashdata and its working, but I am not sure is that a right way to do it.
You can use database or $_GET :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.