简体   繁体   English

PHP会话在wamp5中不起作用

[英]PHP session doesn't work in wamp5

I'm stuck up with php sessions its not working i jus checked for basic programs in session 我坚持使用php会话,但无法正常工作,我已在会话中检查了基本程序

ses.php ses.php

ses1.php The above prog doesn't work. ses1.php上面的编不起作用。 dont know prob wit prog or wamp server. 不知道机智编或WAMP服务器。 I have turned ON register_globals in php.ini also i checked with session.save_path="c:/wamp/tmp" session.save_handler= files. 我在php.ini中也打开了register_globals,我也用session.save_path =“ c:/ wamp / tmp” session.save_handler =文件进行了检查。 pl suggest me to handle with session 请建议我处理会议

thanks in advance. 提前致谢。

Are you creating and closing the session? 您正在创建和关闭会话吗? Does the correct file path exist and is it writeable? 是否存在正确的文件路径,并且可写? (You are using windows, right?) (您正在使用Windows,对吗?)

I would also recommend checking the php configuration from the WAMP admin screen to make sure the session information is correct. 我还建议您从WAMP管理屏幕中检查php配置,以确保会话信息正确。 If you make any changes to the path, you have to restart the web server. 如果对路径进行任何更改,则必须重新启动Web服务器。

Example from: http://php.net/manual/en/function.session-start.php 示例来自: http : //php.net/manual/en/function.session-start.php

<?php
// page1.php

session_start();

echo 'Welcome to page #1';

$_SESSION['favcolor'] = 'green';
$_SESSION['animal']   = 'cat';
$_SESSION['time']     = time();

// Works if session cookie was accepted
echo '<br /><a href="page2.php">page 2</a>';

// Or maybe pass along the session id, if needed
echo '<br /><a href="page2.php?' . SID . '">page 2</a>';
?>

Page2.php Page2.php

<?php
// page2.php

session_start();

echo 'Welcome to page #2<br />';

echo $_SESSION['favcolor']; // green
echo $_SESSION['animal'];   // cat
echo date('Y m d H:i:s', $_SESSION['time']);

// You may want to use SID here, like we did in page1.php
echo '<br /><a href="page1.php">page 1</a>';
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM