JJohnsenDK Posted February 9, 2007 Share Posted February 9, 2007 Why doesnt this script register a session in tmp path? <? session_start(); if(isset($destroy)) { session_destroy(); unset($name); } else { if(!session_is_registered("name")) { session_register("name"); $name = "Spike"; } } ?> <p>SESSID: <?=$PHPSESSID;?> <p>Navn: <?=$_SESSION['name'];?> <form action="session2.php" method="post"> <input type="submit" name="reload" value="Genstart session"><br> <input type="submit" name="destroy" value="Stop session"> </form> Link to comment https://forums.phpfreaks.com/topic/37755-solved-why-doesnt-this-script-register-a-session/ Share on other sites More sharing options...
ToonMariner Posted February 9, 2007 Share Posted February 9, 2007 <? session_start(); if(isset($destroy)) { session_unset(); session_destroy(); } else { if(!is_set($_SESSION['name'])) { $_SESSION['name'] = "Spike"; } } ?> <p>SESSID: <?php echo session_id(); ?> <p>Navn: <?php echo $_SESSION['name'];?> <form action="session2.php" method="post"> <input type="submit" name="reload" value="Genstart session"><br> <input type="submit" name="destroy" value="Stop session"> </form> short tags for php should be banned!!!! Link to comment https://forums.phpfreaks.com/topic/37755-solved-why-doesnt-this-script-register-a-session/#findComment-180617 Share on other sites More sharing options...
obsidian Posted February 9, 2007 Share Posted February 9, 2007 From the PHP Manual: If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister(). So, try this instead: <?php session_start(); if(isset($destroy)) { session_destroy(); unset($_SESSION['name']); } else { if(!isset($_SESSION['name'])) { $_SESSION['name'] = "Spike"; } } ?> Link to comment https://forums.phpfreaks.com/topic/37755-solved-why-doesnt-this-script-register-a-session/#findComment-180618 Share on other sites More sharing options...
JJohnsenDK Posted February 9, 2007 Author Share Posted February 9, 2007 thanks mates Link to comment https://forums.phpfreaks.com/topic/37755-solved-why-doesnt-this-script-register-a-session/#findComment-180624 Share on other sites More sharing options...
camdagr81 Posted February 9, 2007 Share Posted February 9, 2007 Yeah, you have to send a variable to the session in order for it to truely exsist: $_SESSION['var'] = 'value'; Link to comment https://forums.phpfreaks.com/topic/37755-solved-why-doesnt-this-script-register-a-session/#findComment-180779 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.