I am passing the session to next page in loop, where i get different values of $post_id, however it seems to take 1 value, and not changing.
<?php
include('dataconnect.php');
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " .$conn->connect_error);
}
$sql = "SELECT * FROM user";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$post_id = "{$row['id']}";
?>
<a href="comment.php?<?php $_SESSION['user_id'] = intVal($post_id); ?>" >Comment</i></a>
<?php }
}
$conn->close();
?>
Use the session_start() function at the beginning of your scripts.
<?php
session_start();
include "dataconnect.php";
// do stuff...
?>
i changed this, hope this help!
<a href="comment.php?session=<?php echo $_SESSION['user_id'] = intVal($post_id); ?>" >Comment</i></a>