Mainly set cookies when logging in and out. To save login and safe exit
1: Set on the login page
//Set the value of cookies
_setcookies($_rows['tg_username'], $_rows['tg_uniqid'],$_clean['time']);
_location(null,'index.php');
Step 2: Generate cookie,
<span>/*</span><span>* * _setcookies * @param unknown $_username * @param unknown $_uniqid </span><span>*/</span><span>function</span> _setcookies(<span>$_username</span>,<span>$_uniqid</span>,<span>$_time</span><span>){ </span><span>setcookie</span>('username',<span>$_username</span><span>); </span><span>setcookie</span>('uniqid',<span>$_uniqid</span><span>); </span><span>switch</span> (<span>$_time</span><span>) { </span><span>case</span> '0' : <span>//</span><span> 设置浏览器进程</span><span>setcookie</span> ( 'username', <span>$_username</span><span> ); </span><span>setcookie</span> ( 'uniqid', <span>$_uniqid</span><span> ); </span><span>break</span><span>; </span><span>case</span> '1' : <span>//</span><span> 一天的进程</span><span>setcookie</span> ( 'username', <span>$_username</span>, <span>$_time</span> () + 86400<span> ); </span><span>setcookie</span> ( 'uniqid', <span>$_uniqid</span>, <span>$_time</span> () + 86400<span> ); </span><span>break</span><span>; </span><span>case</span> '2' : <span>//</span><span> 一周的进程</span><span>setcookie</span> ( 'username', <span>$_username</span>, <span>$_time</span> () + 604800<span> ); </span><span>setcookie</span> ( 'uniqid', <span>$_uniqid</span>, <span>$_time</span> () + 604800<span> ); </span><span>break</span><span>; </span><span>case</span> '0' : <span>//</span><span> 一个月的进程</span><span>setcookie</span> ( 'username', <span>$_username</span>, <span>$_time</span> () + 2592000<span> ); </span><span>setcookie</span> ( 'uniqid', <span>$_uniqid</span>, <span>$_time</span> () + 2592000<span> ); </span><span>break</span><span>; } }</span>
Step 3: Set
<span>//</span><span>登录的情况,就是防止登陆后通过在浏览器中直接连接再次登录</span><span>function</span><span> _login_state(){ </span><span>if</span> (!<span>isset</span>(<span>$_COOKIE</span>['username'<span>])) { _alert_back(</span>"登录状态无法就行本操作!"<span>); } }</span>
<span>//</span><span>删除cookies</span><span>function</span><span> _unsetcookies(){ </span><span>setcookie</span>('username','',<span>time</span>()-1<span>); </span><span>setcookie</span>('uniqid','',<span>time</span>()-1<span>); _session_destroy();</span><span>//</span><span>删除session</span> _location(<span>null</span>,'index.php'); <span>//</span><span>做跳转</span>}
in login status Step 4 on login page and logout Page plus
<span>//</span><span>登录状态</span> _login_state();
The above introduces the COOKIES of PHP practice project notes, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

我们今天主要是来看一看golang time 包的时间应用方式。两者的一般规则是「wall time」用于告知时间,而「monotonic clock」用于测量时间;除外还有其他的时钟处理方式。

setcookie php失效的解决办法:1、打开相应的PHP文件;2、查看域名参数是否规范;3、通过全局变量来实现即可,代码如“foreach ($_COOKIE["cookie"] as $name => $value) {$name = htmlspecialchars($name);$value = htmlspecialchars($value);echo...”。

1.概述作为本文的一部分,让我们从现有Date和CalendarAPI存在的一些问题入手,来探讨新的Java8Date和TimeAPI如何解决这些问题。我们还将搞一搞Java8时间类库中的核心类,比如LocalDate,LocalTime,LocalDateTime,ZonedDateTime,Period,Duration以及它们的api。2.旧的时间API(java8之前)的问题线程安全-Date和Calendar类不是线程安全的,使开发者难以调试这些api的并发问题,需要编写额外的代码来处

在Web开发中,Cookie是一种非常常见的技术,它允许Web应用程序在客户端存储和访问数据。在PHP编程中,设置Cookie通常使用setcookie函数实现。setcookie函数的语法如下:boolsetcookie(string$name[,string$value[,int$expire[,string$path[,

Pythontime模块时间获取和转换Python的Time库可以进行时间相关的处理,如访问当前日期和时间,输出不同格式的时间以及等待指定的时间等。1.获取时间1.1.时间戳importtimetimestamp=time.time()#1682737552.5009851格林威治时间(GMT)1970年01月01日00时00分00秒起至现在的总秒数1.2.结构化时间importtimestruct_time=time.localtime()#time.struct_time(tm_year=2

一.Python中表示时间的两种方式:时间戳:相对于1970.1.100:00:00以秒计算的偏移量,唯一的时间元组struct_time:共有9个元素>tm_year:年1-12>tm_mon:月1-12>tm_mday:日1-31>tm_hour:时0-23>tm_min:分0-59>tm_sec:秒0-59>tm_wday:星期0-6(0表示周日)>tm_day:一年中的第几天1-366>tm_isdst:是否是夏令,默认为-1二.ti

PHP中的setcookie()函数是将Cookie设置为客户端浏览器的一种方法。它可以让网站在下一次访问时,通过Cookie来识别用户,并为其提供相应的服务。setcookie()有几个参数,其中包括Cookie的名称、值、过期时间等。当设置过期时间时,可以通过时间戳来指定。但是,有时候我们会看到时间戳被设置为0的情况,这究竟表示什么意思呢?

使用PHP函数"time"返回当前的UNIX时间戳UNIX时间戳是指从协调世界时(UTC)1970年1月1日0时0分0秒起至今的总秒数。在PHP中,可以使用内置函数"time"来获取当前的UNIX时间戳。本文将介绍如何使用这个函数,并提供相应的代码示例。代码示例:<?php$timestamp=time();echo"当前的


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!
