Home > Backend Development > PHP Problem > How to use php session_start function

How to use php session_start function

藏色散人
Release: 2023-02-22 19:00:01
Original
4838 people have browsed it

php session_start function is used to start a new session or reuse an existing session. Its syntax is bool session_start ([ array $options = [] ] ). The parameter options is an associative array. If provided, it will be overwritten with the items in it. Configuration items in session configuration directives.

How to use php session_start function

#php session_start function how to use?

Function: Start a new session or reuse an existing session

Syntax:

bool session_start ([ array $options = [] ] )
Copy after login

Parameters:

options This The parameter is an associative array whose items, if provided, will be used to override the configuration items in the session configuration directive. The keys in this array need not contain the session. prefix.

Note:

Returns TRUE if the session is successfully started, otherwise returns FALSE

php session_start() function usage example 1

<?php
session_start();
session_id(1);
session_name("admin");
echo "session_id:".session_id().",session_name:".session_name();
?>
Copy after login

Output:

session_id:1,session_name:admin
Copy after login

php session_start() function usage example 2

<?php
session_start();
session_id(2);
session_name("php中文网");
echo "当前存储的sessionid为".session_id().",存储的session名为:".session_name();
?>
Copy after login

Output:

当前存储的sessionid为2,存储的session名为:php中文网
Copy after login

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

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