Home  >  Article  >  Backend Development  >  How to use php session_start function

How to use php session_start function

藏色散人
藏色散人Original
2019-05-26 09:58:064800browse

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 = [] ] )

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();
?>

Output:

session_id:1,session_name:admin

php session_start() function usage example 2

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

Output:

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

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!

Statement:
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