troubles with flashdata |
[eluser]Fenix[/eluser]
I am having trouble understanding how I can call the flashdata from this particular function (the login function from the ReduxAuth library) in my view. Please take a look at how I'm doing this... what I don't understand is why in the library it's using $this->ci->session-> but when I try to call it with that ci in there, it gives errors. In the Library: Code: public function login ($email, $password) In my controller: Code: switch ($redux) In my view: Code: if(isset($login_message)) I've also tried using just the $this->session->flashdata('login') in my view, that didnt work. Then I tried redirecting to users/login instead of just loading the views in each switch case, still no luck. Please help me out! THanks!
[eluser]JGarrido[/eluser]
So what type of errors/output are you getting? I've been attempting to access the same object with no success. This isn't really relevant to the flashdata, but should help you with troubleshooting/debugging this particular section of code: One thing I noticed that could be problematic is the usage of that switch statement which includes both boolean and string evaluations. I've been evaluating this ReduxAuth library for a couple days, and that specific section gave me tons of trouble due to the fact that the 'switch' statement in PHP does a loose comparison, as opposed to strict (more info here); so when $redux contained a value of 'true', it still fired off the code in the first case block ('NOT_ACTIVATED'). I wound up wrapping it with an additional elseif to determine the return value type and then evaluate accordingly: Code: if(is_string($redux)) { Another option would be to convert the switch to an elseif, would work just as well (and might actually be more concise and efficient, depending on your situation). Aside from that, I've been having issues with the flashdata myself, but I'm new to both CI and ReduxAuth (and PHP in-general, for that matter), so hopefully someone else will be able to provide more insight. A deeper elaboration of the session handling in CI/ReduxAuth in the broader sense would be extremely helpful.
[eluser]Fenix[/eluser]
[quote author="JGarrido" date="1219364627"]when $redux contained a value of 'true', it still fired off the code in the first case block ('NOT_ACTIVATED').[/quote] This was one thing that was happening I'm pretty sure... I would log in with valid credentials but it would tell me NOT_ACCTIVATED... that isn't what it is doing anymore, I've been trying one thing after another so that is behind me for now. I'll give you're method a try and see how it goes. I'll post back in 10
[eluser]Fenix[/eluser]
Now, for some reason, everything works except it is letting me login even if the credentials are flagged as banned... are you having this problem at all?
[eluser]JGarrido[/eluser]
I haven't actually tried the banned scenario yet, as it won't be a feature I'll need for this application. Have you made any changes yet to the switch statement that evaluates $redux?
[eluser]Fenix[/eluser]
Yes, now it looks like this (works too, for what I can tell): Code: if(is_string($redux)) And my logout function is in that same controller: Code: function logout () And here is my view: Code: <h1>Login</h1>
[eluser]Popcorn[/eluser]
This is a bug with Redux, mixed returns and using them in conjunction with a php switch statement doesn't work too well. Glad you got it sorted, this will fixed for version 1.5.
[eluser]steelaz[/eluser]
If I'm not mistaken, you can only read session flashdata (or userdata) when a new page is loaded.
[eluser]Unknown[/eluser]
Try this: switch ((string)$redux) { case 'NOT_ACTIVATED': # code... break; case 'BANNED': # code... break; case false: # code... break; case true: # code... break; } |
Welcome Guest, Not a member yet? Register Sign In |