$cardtype = @$_GET['type']; $_SESSION['cardtype'] = $cardtype; PHP: $cardtype = @$_GET['type']; if($cardtype=="new"){ $_SESSION['cardtype'] = "new"; } if($cardtype=="replace"){ $_SESSION['cardtype'] = "replace"; } if($cardtype=="create"){ $_SESSION['cardtype'] = "create"; } PHP: why the session in first code cannot hold the value of $cardtype. when i try to change the code to the second code, then the session can hold the value of $cardtype to the following page. it is weird. i wonder why the first code cannot display the value? it should be can be displayed.
If the PHP directive register_globals is set to on then session values will also be made into variables. try to change different name for session. example : $_session[ctype] = $cardtype;
ok the reason is that on the first code the session variable is set to blank if you go to that page and $_GET['type'] is not set . where as the second one if its not set to something specific it doesnt write to the session variable