English 中文(简体)
PHP 会话和曲奇要删除吗?
原标题:PHP Sessions & Cookies Getting Deleted?
  • 时间:2012-05-22 11:24:09
  •  标签:
  • php
  • cookies

在两个铬 & amp; Firefox 上, 它持续大约一个小时, 然后会话曲奇, 由 Javascript 设置的其他曲奇消失。 我甚至没有关闭浏览器 。

session_set_cookie_params(946080000); // 30 years
session_start();
$_SESSION[ login ]=true;

离开。 会话曲奇已经消失。 我认为它不是浏览器, 因为它消失在Chrome & amp; Firefox上。 我没有在 IE 上测试 。

这是正常的行为吗?

抱歉,我知道我没有提供多少信息,但这是因为没有太多信息可以提供。它应该有效,但是没有。

问题回答

我认为你做错了, 如果可能的话, 请修改php. ini, 以反映您想要应用的 cookie 持续时间。 从php. net 手册读取 :

"Set cookie parameters defined in the php.ini file. The effect of this function only lasts for the duration of the script. Thus, you need to call session_set_cookie_params() for every request and before session_start() is called.

This function updates the runtime ini values of the corresponding PHP ini configuration keys which can be retrieved with the ini_get()."

这意味着您需要在做一个会话_start () 之前在您所有的php 文件中称它为 EveryTIME 。 可能有一个解决方案的博客文章 : http://blog.centresource.com/2006/05/23/php-session-lifer- lifer- an- advency/

要更改 PHP Ini 使用下行的值 :

php_value session.gc_maxlifetime "946080000"

无论如何,它最好使用椰子, 会话不会用很长的寿命, 而是用饼干来代替。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签