• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A question regarding the Session Class

#1
[eluser]EEssam[/eluser]
Hello,

I do not understand what is so good in having the following information available:

[array]
(
'session_id' => random hash,
'ip_address' => 'string - user IP address',
'user_agent' => 'string - user agent data',
'last_activity' => timestamp
)

How can this help me in creating a member area, for example?

Please clarify. Thanks.

#2
[eluser]Matthieu Fauveau[/eluser]
These values are actually used by the session class itself to keep track of the users, nothing else...

#3
[eluser]Crimp[/eluser]
You can put any information you want in the session (up to its limit). The above data is included in the session class by default.

To create a member area, with restricted access, you can for exmaple set session data called "logged_in" to TRUE.

Your session userdata array wil then be:

Code:
[array]
(
‘session_id’ => random hash,
‘ip_address’ => ‘string - user IP address’,
‘user_agent’ => ‘string - user agent data’,
‘last_activity’ => timestamp,
'logged_in' => TRUE
)

In your member area methods you can then check for:

Code:
if ($this->session->userdata('logged_in'))
{
// do if logged in
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.