note 59741 deleted from function.session-register by dmytton

From: Date: Wed, 14 Dec 2005 18:40:35 +0000
Subject: note 59741 deleted from function.session-register by dmytton
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-100149@lists.php.net to get a copy of this message
Note Submitter: vangelier at hotmail dot com Reason: useless ---- He there, I was trying sessions, but came up with a very bad problem. I'll try to show yah. Script 1 is a simple submit form. If you put session_start() after the post as below, you won't be able to see anything in $_SESSION on Script 1 (wrong way) //Script 1 <?php if($_POST[verder]){ session_start(); session_register("addid"); $_SESSION["addid"] = 1; header("Location: script2.php"); die(); } ?> // Script 2 <?php session_start(); print_r($_SESSION); <--- Nothing there ?> //--------------------------- (rightway) //Script 1 <?php session_start(); if($_POST[verder]){ session_register("addid"); $_SESSION["addid"] = 1; header("Location: script2.php"); die(); } ?> // Script 2 <?php session_start(); print_r($_SESSION); <--- Now you will see value 1 ?>

« previous php.notes (#100149) next »