Home > Backend Development > PHP Tutorial > How to use session in php WeChat public development platform

How to use session in php WeChat public development platform

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-29 09:13:40
Original
1526 people have browsed it

Sessions are stored on the server side, so to distinguish each user's session, you need to use the client's cookie. The WeChat server does not send cookies to the developer server, so cookie-based sessions cannot be used.

But as long as a unique session_id is set for each user, the same effect can be achieved.

Everyone’s WeChat ID is unique, so we can use WeChat ID as the user’s session_id, or we can use it after md5 encryption.

Set ToUserName as session_id as follows

  $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
  if(!empty($postStr)){
      $msg = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
      $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];  if(!empty($postStr)){        
      $msg = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
      //设置session_id
      session_id($msg['ToUserName']);
      session_start();
  }
Copy after login

The above introduces how to use session on the PHP WeChat public development platform, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
Latest Issues
Session
From 1970-01-01 08:00:00
0
0
0
session
From 1970-01-01 08:00:00
0
0
0
session login information
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template