Hey guys and gals, I've got a little problem I've been working on for a few days now. I want to be able to store session information in my mysql database. I've read more tutorials on it than I can shake a stick at, but they haven't helped me at all. Even the ones that seem designed to do precisely what I want don't work. I've been doing some trial and error for the past day, but I haven't gotten anywhere useful.
So basically, while I continue my trial and error, I just wanted to put word out there, to see if someone can help me come up with the code.
**this is not a homework assignment or anything, just a little side-project of mine, so don't hold back, folks**
Anyway, I have a table called sessions, and the fields: session_Id, expiration, value.
Expiration is the current time plus the max life of the session, and value is the session data.
Currently, I have a command in the write() function (I'm creating a custom session handler) that should insert or update the table with new session information. The problem is that it does not work. I even echoed the data I wanted to insert right beneath it, and the data is there, just my mysqli commands are not working.
Here's code for consideration:
Code:
function write($id, $data)
{
$newid = mysql_real_escape_string($id);
$newdata = mysql_real_escape_string($data);
$dbc = mysqli_connect('localhost','user','pass','database');
$arg = "REPLACE sessions(session_Id,expiry,value) VALUES('$newid',time(),'$newdata')";
$result = mysqli_query($dbc, $arg);
return true;
}
Yeah, I know the time variable doesn't do what I wanted it to do, but I was just trying to get it to insert
something.
I've gotta run right now, so if there's any other bit of code or information you need from me, let me know and I'll get it up asap. Thanks, guys.