Welcome Guest, Not a member yet? Register   Sign In
$session is not accessible to view
#5

(06-28-2020, 12:56 AM)@nuj_3313 Wrote: Thanks! it's work!
But is it really required to assign it to view, is it not available automatically, I mean I also have to use the URI segment and other things also so everything needs to pass to the view?

It is necessary to pass any needed data to the view explicitly. The reason is that the "view" is in a different scope than the controller.

However, keep in mind that the Session class is a wrapper around the Superglobal $_SESSION. You can access that easily from a view. For instance, assuming a person's name is saved in the session you should be able to do this in a view.

PHP Code:
<div><?= $_SESSION['name']; ?></div> 
Reply


Messages In This Thread
$session is not accessible to view - by @nuj_3313 - 06-27-2020, 11:53 PM
RE: $session is not accessible to view - by dave friend - 06-28-2020, 06:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB