search
HomeBackend DevelopmentPHP7Notes on session_start in PHP7!

Notes on session_start in PHP7!

Jul 25, 2020 pm 04:05 PM
session_start

Notes on session_start in PHP7!

PHP7 Notes on session_start will cause the browser page not to update

Related recommendations: " php session session (topic)

Please see the code

//PHP7中session_start 使用注意事项,
session_start([
    'cache_limiter' => 'private', //在读取完毕会话数据之后马上关闭会话存储文件//启用后,浏览器刷新时,页面将不再请求服务器刷新,只能使用CTRL+F5刷新才重新请求数据,慎用!
    'cookie_lifetime' => 3600 ,  //SessionID在客户端Cookie储存的时间,默认是0,代表浏览器一关闭SessionID就作废
        'read_and_close' => true   //在读取完会话数据之后, 立即关闭会话存储文件,不做任何修改//启用后不能修改,不能销毁SESSION
]);
$tmd = $_GET['tmd'] ?? 1;
refreshUrl("admin_login.php",$tmd);
/*浏览器刷新时,更新URL地址,防止页面缓存*/
function refreshUrl($url, $tmd)
{
    $waitTime = microtime(true) - $tmd;
    if ($waitTime > 1) {
        jmpUrl($url);
        die();
    }
}
/*url跳转加随机数,防止页面缓存*/
function jmpUrl($url)
{
    if (!strpos($url, '?')) {
        header("Refresh:0;url=" . $url . "?tmd=" . microtime(true));
    } else {
        header("Refresh:0;url=" . $url . "&tmd=" . microtime(true));
    }
}

Related topic recommendations:php session (including pictures Text, video, case)

The above is the detailed content of Notes on session_start in PHP7!. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:segmentfault. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Will R.E.P.O. Have Crossplay?
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor