Welcome Guest, Not a member yet? Register   Sign In
still losing session userdata across a redirect
#23

(12-04-2017, 03:17 PM)dave friend Wrote:
(12-02-2017, 01:42 PM)skunkbad Wrote: I don't think anyone else has mentioned it, but I've learned that there can be problems with the order that you set session data and do the redirect. I always set the redirect before writing to the session. I've had problems changing that order in the past.

I must not understand what you mean by "set the redirect". What I think when I read "set the redirect before writing to the session"  is code like this.

PHP Code:
redirect('somewhere');
$_SESSION['item'] = 'xyz'

Which is nonsense since the CI function redirect() does not return meaning the next line of code will never have a chance to execute.

So, what do you mean?

I use PHP's header function, which does not use exit. Years ago I was having problems with a redirect and session combination, and I read somewhere that the redirect needs to be done before the session write, so I've been doing it that way ever since. That's all I know, and if it's wrong then I don't know much Smile
Reply


Messages In This Thread
RE: still losing session userdata across a redirect - by skunkbad - 12-04-2017, 08:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB