Have some of you some decisions, please tell me.
Sessions
Moderator: General Moderators
-
OlezhkaPoi
- Forum Newbie
- Posts: 6
- Joined: Fri Oct 24, 2003 12:25 pm
- Contact:
Sessions
I have got an array of data to store in session. But when the data is already in session, after next action it's dissapeared.
Have some of you some decisions, please tell me.
Have some of you some decisions, please tell me.
Try this sample code to get a feel for how it works. I tried several other examples I found in the message posts and none of them worked. Remember that if you're not destroying sessions during development, it's probably a good idea to exit and restart your browser when changing session related code. Hope this helps
Code: Select all
<?php
session_start();
header("Cache-control: private");
?>
<html>
<head>
<title></title>
</head>
<body>
<?php
if($sessVar == 0)
{
session_register('sessVar');
$sessVar = 1;
$sArr = array(0,0,0,0);
session_register('sArr');
}
else
{
$sessVar++;
for($i=0; $i<sizeof($sArr); $i++) {
$sArrї$i] += $i+1;
}
}
for($i=0; $i<sizeof($sArr); $i++) {
echo "sArrї".$i."]= ".$sArrї$i].", ";
}
echo ("<p><br>");
echo "sessVar = ".$sessVar."<p><br>";
?>
<a href="sesstest.php">Test</a>
</body>
</html>-
OlezhkaPoi
- Forum Newbie
- Posts: 6
- Joined: Fri Oct 24, 2003 12:25 pm
- Contact:
Sessions
Thanks for advice, but it's still wiping the Arrays values. I think it must be something wrong with a php.ini. If you have some decisions, please write me!

-
OlezhkaPoi
- Forum Newbie
- Posts: 6
- Joined: Fri Oct 24, 2003 12:25 pm
- Contact:
please try your script withif this doesn't work, what does?
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
session_start();
[...remaining part of your script...]
session_write_close();
?>Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
session_start();
$sessionIdA = session_id();
@$_SESSION['counter'] += 1;
session_write_close();
// restart session
session_start();
$sessionIdB = session_id();
?>
<html>
<head>
<title>session test</title>
</head>
<body>
<?php
echo $sessionIdA,'<br />', $sessionIdB, '<br />';
echo 'session counter: ', @$_SESSION['counter'];
session_write_close();
?>
<a href="<?php echo $_SERVER['PHP_SELF']; ?>">refresh</a>
</body>
</html>-
OlezhkaPoi
- Forum Newbie
- Posts: 6
- Joined: Fri Oct 24, 2003 12:25 pm
- Contact:
Sessions
Has worked! As soon as I have inserted the following code
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
The prevention that the file in a directory/tmp cannot be read as directories do not exist has appeared, or the true way is specified not
Appeared, that I did not have in general such directory then I have created her.
I and thought, that a mistake trifling.
Thanks all for the offered decisions.

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
The prevention that the file in a directory/tmp cannot be read as directories do not exist has appeared, or the true way is specified not
Appeared, that I did not have in general such directory then I have created her.
I and thought, that a mistake trifling.
Thanks all for the offered decisions.