0

I get the MVC thing. :) I swear I do.

So, I have the main controller that serves up either the Home 'view' or a Login/Registration 'view' based on if the user is logged in.

Works fine and dandy.

On registration an email link is sent, which the user needs to click to verify the account->email, this happens to be a function in the Home controller that fires off a model is the link is valid.

Now, inside this model is the code to update the database with A: Activated/Not, B: Try Count.

Now, once this is done, I want to display the Login/Register 'view' with an appropriate message (failed, not failed, tried too many times, etc...)

I was going to use a redirect and throw the message type, and message text in a session variable and just display it that way, but then got to thinking that I could bypass that by firing off the Home controller index function passing in an array variable containing the message type, and message text.

Boy was I wrong.

So, how can I do this? I'd really like to stay away from relying on sessions

3
  • Do you want to redirect to the home/index method as a redirect? you can try using POST or just send the message key and build a function with the messages texts Commented Apr 15, 2015 at 21:54
  • 1
    i would suggest to put all login related methods in a separate controller. then everything about confirming the login, the email, etc - it all happens from the specific login controller. Commented Apr 15, 2015 at 22:42
  • All login related material is in it's own model. However, rather than redirecting from the Home page to the Login/Registration page if the user is not logged in, I simply load in the Login/Registration view in the Home controller Commented Apr 16, 2015 at 12:04

1 Answer 1

1

The respective method of Model should return a value (probably an array) that contains status and count (pseudo-code)

$statusCount = $model->getStatusCount($input);

And later pass the data to View

$view->set('statusCount', $statusCount);

So answering the question: yes, you can evade the $_SESSION.

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

2 Comments

Yeah I'm finding sessions to be sketchy at best. #1 on their own, #1 CI's built-in :)
Bingo. Here's what I did. I set a couple of private variables for both msgType and message, fire off what I need, grab the return and check it if valid. If valid, set the properties, and refire $this->index()

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.