| | |
SESSION variable problem
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2008
Posts: 495
Reputation:
Solved Threads: 0
This is content of in.header.php
This is index.php which also has form objects that POSTs other values to step1.php
This is step1.php
Problem is print_r prints only
What do i miss?
Thanks in advance
PHP Syntax (Toggle Plain Text)
if(!isset($session_id) || empty($session_id)) { session_start(); $_SESSION["Inputs"]=array(); }
This is index.php which also has form objects that POSTs other values to step1.php
PHP Syntax (Toggle Plain Text)
require_once 'inc.header.php' $_SESSION["Inputs"]["name"]="MyName"; $_SESSION["Inputs"]["surname"]="MySurname";
This is step1.php
PHP Syntax (Toggle Plain Text)
require_once 'inc.header.php' $_SESSION["Inputs"]["age"]=$_POST["textboxAge"]; print_r($_SESSION["Inputs"]);
Problem is print_r prints only
Array (). I cannot see name, surname and age.What do i miss?
Thanks in advance
•
•
Join Date: Jan 2008
Posts: 141
Reputation:
Solved Threads: 19
Hi,
If you haven't already read the function description for session_start(), read it here.
You have to call session_start at the beginning of every new page to continue the previous session. You may also find it beneficial to use session_name.
Check out the examples on the link I included.
R.
If you haven't already read the function description for session_start(), read it here.
You have to call session_start at the beginning of every new page to continue the previous session. You may also find it beneficial to use session_name.
Check out the examples on the link I included.
R.
PHP Syntax (Toggle Plain Text)
if(!isset($session_id) || empty($session_id)) { session_start(); $_SESSION["Inputs"]=array(); }
It's not clear where $session_id is declared if at all, therefore the code will always run regardless of whether you have a $_SESSION variable. In addition, $_SESSION["Inputs"]=array(); may overwrite previous $_SESSION variables, leaving you with an empty array.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
•
•
Join Date: Apr 2008
Posts: 495
Reputation:
Solved Threads: 0
Solved.
inc.header.php
index.php
next.php
inc.header.php
PHP Syntax (Toggle Plain Text)
<?php session_start(); ?>
index.php
PHP Syntax (Toggle Plain Text)
<?php require_once 'inc.header.php'; $_SESSION["Inputs"]["name"]="MyName"; $_SESSION["Inputs"]["surname"]="MySurname"; echo "<pre>"; print_r($_SESSION["Inputs"]); ?> <form action="next.php" method="post"> <input type="textbox" name="age" value="15" /> <input type="submit" name="submit" value="send" /> </form>
next.php
PHP Syntax (Toggle Plain Text)
<?php require_once 'inc.header.php'; $_SESSION["Inputs"]["age"]=$_POST["age"];; echo "<pre>"; print_r($_SESSION["Inputs"]); ?>
![]() |
Similar Threads
- ASP.NET - session objects Problem (ASP.NET)
- Session variable keeping login information (ASP.NET)
- Session Variable clashing (ASP.NET)
- Losing session variable problem...help! (ASP)
- session variable undefined in MX 6.1, works in CF 5 (ColdFusion)
- Session variable (ASP.NET)
- session variable:again (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: Crystal report with PHP
- Next Thread: Request for Max Upload Filesize Change
| Thread Tools | Search this Thread |
apache api archive array autocomplete beginner binary broken cakephp checkbox class cms code cron curl database dataentry date display duplicates dynamic ebooks echo email emptydisplayvalue error execute explodefunction file files firstoptioninphpdroplist folder form forms function functions google href htaccess html image include insert ip javasciptvalidation javascript joomla keywords limit link login mail matching mediawiki menu mlm multiple mysql number oop paypal pdf php phpincludeissue problem query radio random recursion recursive remote script search server sessions shot sms source sp space speed sql subdomain subscription syntax system table tag tutorial tutorials update upload url validator variable vbulletin video web white youtube





