i need session variables. i've used them before, it's been while, , evidently i'm missing something. coded following example demonstrating how think session variables should work i'm missing something. value submitted page1.php, value passed page2.php. session variable populated, displays correctly on page2.php but, once go page1.php, variable empty. where's screw up? thank you!
/* page1.php code ============================== */ <?php session_start(); ?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>page 1</title> </head> <body> <form method='post' id='pf' action='page2.php'> <input type='text' id='box_inp' size='1' name='pbox'/> <input type="submit" value="submit"> </form><br/><br/> <?php print_r($_session); ?> </body> </html> /* page1.php end ============================== */ /* page2.php code ============================== */ <?php session_start(); $_session["x_test"] = $_post["pbox"]; ?> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>page 2</title> </head> <body> <?php print_r($_session); ?> <br/><br/> <a href="page1.php">back</a> </body> </html> /* page2.php end ============================== */
ok code works fine. looks problem coming confirguration. check session configuration in php.ini. here manual. http://php.net/manual/en/session.configuration.php
and here full standard configuration session config should work :
session.save_handler = files session.use_only_cookies = 1 session.name = phpsessid session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.bug_compat_42 = on session.bug_compat_warn = on session.referer_check = session.cache_limiter = nocache session.cache_expire = 180
Comments
Post a Comment