English 中文(简体)
如何打断PHP届会的空洞问题?
原标题:How to troubleshoot PHP session file empty issue?
  • 时间:2010-03-26 05:27:09
  •  标签:
  • php
  • session

我拥有一个PHP会议的甚微页面。

<?php
session_start();

if (isset($_SESSIONS[ views ]))
{
    $_SESSIONS[ views ] = $_SESSIONS[ pv ] + 1;
}
else
{
    $_SESSIONS[ views ] = 0;
}

var_dump($_SESSIONS);

?>

该网页经过更新后,总是显示

array
   views  => int 0

环境是XAMPP 1.7.3。 我检查了phpInfo()。 会议得以举行。

Session Support     enabled
Registered save handlers    files user sqlite
Registered serializer handlers  php php_binary wddx

Directive   Local Value Master Value
session.auto_start  Off Off
session.bug_compat_42   On  On

当页面访问时,我的“D:xampp mp”文件夹中设立了“会议”。 但内容是空的。

在大火中,我可以看到本届会议的 co。

Cookie  PHPSESSID=lnrk7ttpai8187v9q6iok74p20

看来,会议数据并不流利于档案。

是否有办法或方向解决问题?

感谢。

最佳回答

BTW, is $_SESSION not $_SESSIONS

因此,它没有节省数据。

问题回答

我们需要确定的变量称为<代码>_SESSION而不是_$_ 页: 1

在这方面,我做了些什么......

  • 在工厂,如果早于php5(因违约而重归并和扶持)5。

  • 在您的php.ini(就地点而言,见phpinfo()或可操作>php-i)改变了行文。

会 议:save_handler = 档案

纽约总部

会议:save_handler = sqlite

  • Then in the same file (php.ini) make sure NOTICES are turned on

错误——报告 = E.ALL

  • restart apache if you changed php.ini

页: 1

Now you will be getting a sensible error message most likely revealing you dont have correct permissions 纽约总部your session.save_path so ...

  • Find out your web services user and group unless known. There are several ways 纽约总部do so but I placed this line temporarily in my php code ...

印刷机(主食-植被(植被));

我发现,用户www-data和团体www-data被我的笔录为这一网络用户。

  • 为网站用户提供网页上的会议名录(可能是/var/www)。

    sudo mkdir /var/www/whatever; sudo chown <user_from_last_step>:<group_from_last_step> /var/www/whatever

    eg>sudo chown www-data:www.data /var/www/whatever

  • 同样,在您的网址(www.php.ini)中,确保会议举行。 除此以外,还发表评论,例如......。

;会议:save_path = /var/lib/php5

不适用

会议:save_path = /var/lib/php5

  • 如经编辑,可重新启用。

  • Now go 纽约总部your php code (Many have a SetEnv.php ish type script which does some global stuff and is imported by all files) and add the following line BEFORE you call session_start() ...

(届会,0;0750;/var/www/whatever)

Note that we set session.save_path in your code rather than in php.ini 纽约总部help keep it secure, so 纽约总部replace whatever with something inventive would be useful.

By now it should appear 纽约总部be working, 不适用 quite, it doesent work accross ajax requests for some reason that I dont care about related 纽约总部sqlite ... so ...

  • Go back 纽约总部your php.ini file and change the line ...

会议:save_handler = sqlite

页: 1

会 议:save_handler = 档案.

  • restart apache

固定: 希望:

使用_SESSION美元,并用打印机($_SESSION)加以核对;

              <?php
                 session_start();

             if (isset($_SESSION[ views ]))
              {
                 $_SESSION[ views ] = $_SESSION[ pv ] + 1;
              }
             else
             {
              $_SESSION[ views ] = 0;
             }
              echo "<pre>";

              print_r($_SESSION);

              ?>




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...