Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How can PHP restrict access to pages only in Wechat's own browser?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

The content of this article mainly explains "PHP how to restrict page access to Wechat's own browser", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how PHP restricts page access to Wechat's own browser".

In order to prevent their hard-working webapp from being copy, we all want to limit the program to browsing in Wechat, although the following realization of this function, a single piece of cake, not much technical content, understand the code under the forgery of the broken. The following is the code that PHP restricts the page to be accessed only in Wechat's own browser.

The copy code is as follows:

$useragent = $_ SERVER ['HTTP_USER_AGENT']

If (strpos ($useragent, 'MicroMessenger') = false) {

Echo "No access to non-Wechat browsers"

} else {

Echo "Wechat browser allows access"

}

If the above code is not perfect, Windows phone's Wechat will not work, so modify it:

The copy code is as follows:

$useragent = addslashes ($_ SERVER ['HTTP_USER_AGENT'])

If (strpos ($useragent, 'MicroMessenger') = false & & strpos ($useragent,' Windows Phone') = false) {

Echo "access to www.buyerinfo.biz is prohibited by non-Wechat browsers"

} else {

Echo "Wechat browser allows access to www.buyerinfo.biz"

}

You can judge by getting HTTP_USER_AGEN.

At this point, I believe that the "PHP how to achieve restrictions on page access can only be included in Wechat browser" have a deeper understanding, might as well to practical operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report