Re: sessions not working



Delirium tremens escribió:
<?php
session_start();
if (isset($_POST[submit])) {
if(!isset($_SESSION['cheese'])) {
$_SESSION['cheese'] = 1;
} else {
$_SESSION['cheese']++;
}
}

?>
<html><head><title>Session Test</title></head>
<body>
Current Session Variable value is: <?= $_SESSION['cheese'] ?> <br/>
<form method="post">
<input type=submit value=click name=submit>
</form>
</body>
</html>

This is what I get:

Notice: Use of undefined constant submit - assumed 'submit' in C:\Documents and Settings\ALVARO\Mis documentos\tmp\borrame.php on line 3
Current Session Variable value is:
Notice: Undefined index: cheese in C:\Documents and Settings\ALVARO\Mis documentos\tmp\borrame.php on line 14


You need to configure your dev box so you can see all error messages. Find your php.ini and set these directives:

display_errors = On
error_reporting = E_ALL | E_STRICT


Apart from this, the code works for me. Run phpinfo() and find the "session" section. Check that "Session Support" is "enabled" and make sure that the session.save_path is valid and writable. Also, check that your browser and firewall are not blocking session cookies.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
.