Welcome Guest, Not a member yet? Register   Sign In
sessions
#1

[eluser]ebuoe_007[/eluser]
i'm new to codeigniter and usually when when working with sessions i do create them when users log in to the site then i put a verification code on top of each page viewable by the user to ensure that the user is allowed to view the page and when the user log's out the session is destroyed but,going through CI documentation it said something like the session will be created automatically and expire on its own.

Q:how do i ensure the verification of users using session in CI.do i need to put verification code on each page like i used to ?
#2

[eluser]WanWizard[/eluser]
When a user logs in, you normally would create a session variable to indicate that a user has logged in. At every page load you check this variable, and if present, you know the logged-in user.

There are some config variables in config.php that control session behaviour. 'sess_time_to_update' indicates the time in seconds after which the session will be regenerated (ie will get a new session id). Another one is 'sess_expiration', which is the inactivity timer. If a session is inactive for more than this time, it will be destroyed.
#3

[eluser]ebuoe_007[/eluser]
thanks for your contibution,so is there any need to include user's(peron who just logged in)data in the session array.if yes can it be used?


one more thing is there need to put any code on any page whereby you want to restrict access
#4

[eluser]WanWizard[/eluser]
If you want to do further access checks, your code needs to know which user is logged in. Therefore you should store the user identification (whatever you use) in the session, so it can be retrieved at subsequent requests.

There are a million ways to deal with access control, it's not easy to write a howto in a single post. Have a look first at one of the many authentication libraries posted here, before you decide on writing your own. One of them will probably do the trick, and using it will save you lots of development time.
#5

[eluser]ebuoe_007[/eluser]
thanks a lot




Theme © iAndrew 2016 - Forum software by © MyBB