Renlok Posted February 22, 2007 Share Posted February 22, 2007 around my site im using loads of sessions to tell the user different things. on every page they work fine execpt one where i think it sets the session but the session has no value. i think it sets it atleast as i use isset() function to check if its set then if it is it sould print out a small image then the value of the session but all it shows is the little image. the code in question is as follows: <?php session_start(); include("/home/renlok/public_html/action/func.php"); include("/home/renlok/public_html/includes/config.php"); //check logged in if (!isset($_COOKIE['mysite_username'])) { $_SESSION['message'] = "Please login"; header('location: http://www.roeonline.co.uk/'); } // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $messagein = $_POST['message']; $topic = $_GET['topic']; //checks if there is a message $lenght = strlen($messagein); if($lenght == 0) { echo "It appears you have not entered a message"; header("Refresh: 2; URL=\"http://www.roeonline.co.uk/forum/topic.php?topic=$topic\""); exit; } //sort out entered html $messagehtmlfix = htmlspecialchars($message); //stick bb code in $message = bb2html($messagehtmlfix); $username = $HTTP_COOKIE_VARS['mysite_username']; $query = "SELECT * FROM users WHERE md5='$username'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $user = $row['id']; $query = "insert into forumposts (message, poster, topic) values ('".$message."', '".$user."', '".$topic."')"; $result = mysql_query($query); //lastupdate checker $lastupdate=time(); $topicquery = mysql_query("UPDATE forumtopics SET lastupdate='$lastupdate' WHERE id='$topic'"); $topicquery2 = mysql_query("UPDATE forumtopics SET lastposter='$user' WHERE id='$topic'"); //setting event $points = $row['points']; //get random points $x = rand(1,4); $y = rand(1,4); $z = rand(2,18); $postreward = ($x*$y)+$z; //give user points $newpoints = $points+$postreward; //set event session $_SESSION['event'] = "You earned $postreward points for posting"; $sqlreward = "UPDATE users SET points='$newpoints' WHERE id='$user'"; $runreward = mysql_query($sqlreward) or die($sqlreward.mysql_error()); header("Location: http://www.roeonline.co.uk/forum/topic/$topic.php"); ?> the session im having problems with is $_SESSION['event'] near the bottom, the other $_SESSION['message'] seems to work fine and the 'event' one used to work but stoped working all of a suddun for no reason what so ever. Link to comment https://forums.phpfreaks.com/topic/39720-session-setting-problems/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.