douchi0638
2013-01-23 00:50
浏览 42
已采纳

php会话没有从一个页面转到下一个页面

I've used sessions before on shared hosting and they were very simple. I'm now using Amazon and have linux server with the following configuration in php. The catch is session variables don't carry on from one page to the next:

session

Session Support enabled
Registered save handlers    files user memcached
Registered serializer handlers  php php_binary

Directive   Local Value Master Value
session.auto_start  Off Off
session.bug_compat_42   Off Off
session.bug_compat_warn Off Off
session.cache_expire    180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no value    no value
session.cookie_httponly On  On
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_file    no value    no value
session.entropy_length  0   0
session.gc_divisor  1000    1000
session.gc_maxlifetime  604800  604800
session.gc_probability  1   1
session.hash_bits_per_character 5   5
session.hash_function   0   0
session.name    PHPSESSID   PHPSESSID
session.referer_check   no value    no value
session.save_handler    files   files
session.save_path   /var/lib/php/session    /var/lib/php/session
session.serialize_handler   php php
session.use_cookies On  On
session.use_only_cookies    On  On
session.use_trans_sid   0   0

Sample Page: http://www.datingjapan.co/index.php

Code: index.php

<?php
session_start();
error_reporting(E_ALL & ~E_NOTICE);
$_SESSION['domain'] = 'www.datinggirls.co';
print_r($_SESSION);
?>

<h1>This is the HTML</h1>
<a href="page.php">Visit W3Schools</a>

page.php

<?php
session_start();
$_SESSION['page2'] = 'page-two-data';
print_r($_SESSION);
?>

<h1>This is page 2</h2>
<a href="index.php">Visit Home Page</a>

Any advise... ?

thx

图片转代码服务由CSDN问答提供 功能建议

我之前在共享主机上使用过会话,它们非常简单。 我现在正在使用亚马逊并在php中使用以下配置的linux服务器。 问题是会话变量不会从一个页面继续到下一个页面:

  session 
 
Session支持启用
注册保存处理程序文件用户memcached 
注册序列化程序处理程序php  php_binary 
 
指示本地值主值
session.auto_start关闭
session.bug_compat_42关闭
session.bug_compat_warn关闭
session.cache_expire 180 180 
session.cache_limiter nocache nocache 
session.cookie_domain no value no value 
session。  cookie_httponly On On 
session.cookie_lifetime 0 0 
session.cookie_path / /
session.cookie_secure Off Off 
session.entropy_file no value no value 
session.entropy_length 0 0 
session.gc_divisor 1000 1000 
session.gc_maxlifetime 604800 604800 
session。  gc_probability 1 1 
session.hash_bits_per_character 5 5 
session.hash_function 0 0 
session.name PHPSESSID PHPSESSID 
session.referer_check no value no value 
session.save_handler files files 
session.save_path /  var / lib / php / session /var/lib/php/session
session.serialize_handler php php 
session.use_cookies On On 
session.use_only_cookies On On 
session.use_trans_sid 0 0 
   \  n 
 

示例页面: http://www.datingjapan.co/index.php

代码: index.php

 &lt;?php 
session_start(); 
error_reporting(E_ALL&amp;  ~E_NOTICE); 
 $ _SESSION ['domain'] ='www.datinggirls.co'; 
print_r($ _ SESSION); 
?&gt; 
 
&lt; h1&gt;这是HTML&lt; / h1&gt; \  n&lt; a href =“page.php”&gt;访问W3Schools&lt; / a&gt; 
   
 
 

page.php

 <  code>&lt;?php 
session_start(); 
 $ _SESSION ['page2'] ='page-two-data'; 
print_r($ _ SESSION); 
?&gt; 
 
&lt; h1&gt;这是 第2页&lt; / h2&gt; 
&lt; a href =“index.php”&gt;访问主页&lt; / a&gt; 
   
 
 

任何建议......?< / p>

thx

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • duanke6249 2013-01-23 00:57
    已采纳

    Each time I ping your domain www.datingjapan.co it gives me a different IP.

    Is your shared hosting on multiple cloud instances ? Probably.

    Then the PHP session files may be stored localy on the first server that displayed the page "index". When you load the second page, you are on another server...

    I agree with Peter, look at the amazon FAQ or support about how your session storage is synchronized (or not).

    已采纳该答案
    打赏 评论
  • dongshan1396 2013-01-23 00:54

    if you are using multiple servers they will each have their own session storage. You should look at post on the amazon support forums about synchronizing the session storage between servers.

    Edit: Here's one such post on SO: How to synchronize sessions using Amazon Web Services (AWS)?

    打赏 评论

相关推荐 更多相似问题