js+php realizes the method of real-time calling of user login status in static page, static page user login_PHP tutorial

WBOY
Release: 2016-07-13 10:10:17
Original
877 people have browsed it

js+php realizes the method of real-time calling of user login status on static page, user login on static page

The example in this article describes the method of js+php to realize real-time calling of user login status in static pages. Share it with everyone for your reference. The specific analysis is as follows:

In program development, the page is often made into a static form of HTML, which can reduce the server load. However, there is also a problem that when a registered user logs in, a prompt that the login is successful or requires login must be displayed on the HTML page. In this way, we must think of other ways to achieve it. Below we use js+php to implement the example. Of course, ajax can also be implemented. The code is as follows:

Copy code The code is as follows:




The static page calls the user login and logout procedures in real time (the web page special effects call the php code)






loginajax.php file, because loginajax.php is called and output in js format, so the code in this file can be displayed correctly because it is output in js format. The code is as follows:
Copy code The code is as follows:
$id = isset( $_get['fid'] )?$_get['fid']:0;
if( !isset($_cookie['vvg']) ){
?>
document.write('Username:');
document.write('');
}
else
{
echo 'document.write('['.$_cookie['realname'],']SpeakExit');';
}
?>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/937092.htmlTechArticlejs+php realizes the method of real-time calling of user login status in static page. The example of static page user login in this article tells about js+ PHP implements a method for static pages to call user login status in real time. Share...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template