Welcome Guest, Not a member yet? Register   Sign In
"legacy" functions vs rolling our own
#1

I was updating my application to limit repeated db queries by storing more info in the session data and am wondering why functions like userdata() are marked as "legacy" in the documentation and we're being encouraged to go straight to the _SESSION variable.

This requires us to roll our own version of userdata() or write "isset($_SESSION[$key]) ? $_SESSION[$key] : NULL;" all over the place (or sub-class the session class and roll our own userdata() there).

I'd be all for removing support for the NULL parameter but having a wrapper that can do basic checks and let us get on with writing our applications is one of the biggest reasons for using a framework.

so, why are some of those basic wrappers around _SESSION "legacy" and presumably going away in a future version?
Reply
#2

If these were going away in the future, they'd be deprecated, which is not the case. They are "legacy" simply because they are inherited from a past time that didn't utilize PHP's own session APIs.

Our manual encourages you to use the $_SESSION superglobal simply because that means less overhead and that if you know how to use a regular PHP session, you also know how to use one in CI - there's no point in learning to use new APIs if you don't need to.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB