Welcome Guest, Not a member yet? Register   Sign In
How can check if a session and cookie is exist ?
#1

[eluser]e.abubakr89[/eluser]
Hi all

I need to way to check if a session and cookie is exist or not !

I tried to test session existence
Code:
if($this->session->userdata('username') != "")
but it return true despite of there's no (username) session

I need your help
#2

[eluser]ηυмвєяσηє[/eluser]
Code:
if(isset($this->session->userdata('username')))
#3

[eluser]e.abubakr89[/eluser]
No, it does not work

Code:
Fatal error: Can't use method return value in write context
#4

[eluser]WanWizard[/eluser]
Have you checked the user guide?

If so, you would have seen "Note: The function returns FALSE (boolean) if the item you are trying to access does not exist"

Code:
if ( $this->session->userdata('username') === FALSE )
{
    // session var does not exist
}
#5

[eluser]e.abubakr89[/eluser]
Thanks All

the method of
Code:
if($this->session->userdata('username') != "")
works successfully
the mistake was from handling it in my code

شكــــراً




Theme © iAndrew 2016 - Forum software by © MyBB