Jump to content

Should I use php Sessions to store certain information?


shortysbest

Recommended Posts

If I am making a "Load more comments" button where it loads, lets say 5 more comments each time you click on it, would it be best to use php sessions to store the id of the last comment loaded? And use that to load the next 5?, continually changing the value of the session to the new id? Or is there a better way of doing this? I had been using hidden textfields to do this.

If I am making a "Load more comments" button where it loads, lets say 5 more comments each time you click on it, would it be best to use php sessions to store the id of the last comment loaded? And use that to load the next 5?, continually changing the value of the session to the new id? Or is there a better way of doing this? I had been using hidden textfields to do this.

 

Why don't you just just pass the id via HTTP and add 5 each time?

maybe somthing like this?

 

change the select query (i assume you're using that)

<?php session_start();
//database connectors here

$_SESSION['number'] = 6; //default
if (isset($_SESSION['number'])){ //if set
    $_SESSION['number']=$_SESSION['number']+5;
}
$query = "SELECT * FROM comments_table WHERE category= 14 LIMIT 1,'$_SESSION['number']'"; //showing number 1-5

//output stuff
?>

 

p.s. i haven't tested it put it could very well work ::)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.