Home > Backend Development > PHP Problem > How to set SESSION_ID in php

How to set SESSION_ID in php

藏色散人
Release: 2023-03-11 20:18:01
Original
2520 people have browsed it

How to set SESSION_ID in php: First create a PHP sample file; then set the Session ID through the syntax "session_id(string [id]);".

How to set SESSION_ID in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to set SESSION_ID in php?

session_id() function introduction

session_id() gets or sets the Session ID

Syntax:

string session_id(string [id]);
Copy after login

If there is no parameter id, it means that only the current Session code, plus parameters means setting the Session code to the newly specified id. Input and return are both strings.

If the parameter ID is not set, it means to obtain the Session ID, otherwise it means to set the Session to the newly specified ID.

Note: IDs are all in string form.

session_id() instance

Get Session ID

<?php
session_start(); 
echo session_id();
// 输出 urles147jbrq3u50b0l6f8hvf0
?>
Copy after login

Set Session ID

<?php
session_id("ilovemanongjc.com");
session_start(); 
    /* http://www.manongjc.com/article/1260.html */
echo session_id();
// 输出 ilovemanongjc.com
?>
Copy after login

[Recommended learning: PHP video tutorial]

The above is the detailed content of How to set SESSION_ID in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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