pacome Posted December 24, 2006 Share Posted December 24, 2006 I'm trying to pass some variables through a session with PHP 4.329 but I can't manage to get them through the pages...My host's has this infoSession Support enabled Registered save handlers files user Directive Local Value Master Value session.auto_start Off Off session.bug_compat_42 Off Off session.bug_compat_warn On On session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.entropy_file no value no value session.entropy_length 0 0 session.gc_divisor 1000 1000 session.gc_maxlifetime 1440 1440 session.gc_probability 1 1 session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path /var/lib/php/session /var/lib/php/session session.serialize_handler php php session.use_cookies On On session.use_only_cookies Off Off session.use_trans_sid Off Off and my script is page 1:<?phpsession_start();session_name('ses');if ($_POST[nicksess]){$nicksess=$_POST['nicksess'];//$nicksess=$_POST[nicksess];//session_register("nicksess");echo "<html><body><a href='page2.php'>go to page 2</a><br>".$_POST['nicksess']." <br>y ".$nicksess."</body></html>";}else {?><html><head></head><body><form action='page1.php' method='POST'><input type='text' name='nicksess'>Name<br><input type='password' name='pass'><br><input type='submit' name='submit' value='submit'></form></body></html><?php}?>and page 2 is:<?phpsession_start();session_name('ses');echo "<html><body>Mi nick es:".$_SESSION["nicksess"]." </body></html>";?>When I put my name I print correctly $_SESSION["nicksess"] and $nicksess, but when I click to page 2 the nick doesn't print! :(any ideas?thanks! Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted December 24, 2006 Share Posted December 24, 2006 You don't store the variable in the $_SESSION array in your first script, so you can't get it in your second script.Change:[code]<?phpif ($_POST[nicksess]){$nicksess=$_POST['nicksess'];?>[/code]to[code]<?phpif ($_POST[nicksess]){$nicksess=$_POST['nicksess'];$_SESSION['nicksess'] = $_POST['nicksess'];?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
pacome Posted December 24, 2006 Author Share Posted December 24, 2006 great it's working just fine!one more question!do I have to call the variable $_SESSION[nicksess] everytime or can I rename it let's say $nick and it will be availble with session_start() in other pages?thank you again Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.