开发者

php $_SESSION array not retaining values stored from previous pages

I am trying to create a form where there are multiple sections. It is actually an online menu ordering system. If you remain on the same section (say.. Appetizer), the values successfully load into $_SESSION and displays in the textbox as value. However, if you switch sections (say.. Soups), the values first loads. But when you submit your order for that particular section/switch sections, it loses the values from Appetizer.

It seems like my session array can only retrieve values from the POST array and fails to retain the va开发者_如何学Pythonlues stored in it originally.

can someone tell me what I did wrong? I'm relatively new at this.

This is where the code is...


Well, let's make sure that sessions are actually working on your server. Try out this snippet of code in it's own file. Refresh it a few times. The counter should increment every time. Does it? Are there any errors reported?

<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_erorrs', true);
session_start();

if(!array_key_exists('counter', $_SESSION))
    $_SESSION['counter'] = 0;

echo "You have visited this page " . $_SESSION['counter'] . "times.";
exit;


session_start();

on top of all pages?


Thanks everyone for your answers. So it turns out the server ran out of space. I tested the code on a different server and it worked just fine!


i think ur overwriting all the values into ur session.so the second time u store the previous value gets nullified. try only to store the values of the item name and quantity .i think this will help

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜