Hello, everyone, I have come again. My page is written as follows: session_start (); if ($ _ SESSION ['admin'] = ''| $ _ SESSION ['id'] ='') {echo '& lt; script & g logon page Session problems
Hello everyone, I'm coming again.
My page is written as follows:
Session_start ();
If ($ _ SESSION ['admin'] = ''| $ _ SESSION ['id'] = ''){
Echo 'script ';
Echo 'parent. location. href = "Login. php ";';
Echo 'script ';
}
------------------------------------------------------
The problem is that when the page is opened, it always prompts an error, and there is no Session ['admin'] variable.
Although the page will continue to be executed, it is always bad to make a mistake.
Do you have any good methods except @ to suppress errors.
------ Solution --------------------
If (isset ($ _ SESSION ['admin']) & isset ($ _ SESSION ['id']) {
Code .....
} Else {
Echo 'script ';
Echo 'parent. location. href = "Login. php ";';
Echo 'script ';
Exit;
}
------ Solution --------------------
Isset determines whether a value has been assigned. this is the same as undefined in js.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.