The behaviour you describe requires either using completely database controlled sessions, or to use the session_set_save_handler for simplicity. That lets you override the functionality of sessions so you can transparently use and modify the session without needing to implement any new control code to the existing scripts. If you set the save handlers, you can use a database or still use the filesystem and use partial database control for things like a timestamp.
This is only relevant if you want to aggregate the session data. So to see how many people are online for example. If you just want to know the last time there was activity for a user, you can store that in the session itself (only that user will have access to it though).
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
ok, i read everything you guys referenced and i'm still lost
using the $_SESSION variable is fine, i understand that.
but when i try to assign that "text" value to a different variable, like an object literal or something, and then "post" that info to the mysql database, it all just does not want to happen. nothing crashes, its just that the value of the username never makes it to the database.
i was reading about the session set save handler, sounds easy,... oh boy, looking at the code, totally lost.
this should be easy, so i would assume.
i was splashing out the username on the screen just to test that i can access that value as a text string accurately
i need to store the username in the db, because my user will select changes to graphics on the home page, then a different user comes along and does the same thing, then another, and so on. each time a user is logged on and changes the graphic to one of the preset options, i log who made the change. only one user can be logged on at any one time. so i'm simply tracking who the users are and when they are on the sight and what changes they made to the preset graphic options.
i may need to splash out the username on the main page later, but for now it's just going in the database for my log.
I assume that should do what it looks like it should do. Doh I don't know PHP
Originally Posted by Paul Williams
var a = <?php echo $_SESSION['MM_Username']; ?>
but that doesn't work either.
What do you mean it does not work ?
And prove that it works.
I would formulate the saying prom previous post that some suggested it to you a bit different: When server spits whatever it spits to client, then it (the server) would not know what is on client even if you kill it (the server) (-:
From my previous post: Google for exception handling and you will find text like (no matter which language): try...except ... finaly
It means, whatewer seems did nothing, it probably means that you can get what went wrong after except part of code.
$_SESSION['MM_Username'] is something that comes from using dreamweaver. I would not trust it nor use it. When a user logs into a site they are normally asked for their user name and their password. So you should have their user name as a variable already. I was thinking that you would set a session variable to that along with the log in time and not use $_SESSION['MM_Username']. I then thought that you could use sessions to keep track of "what they were doing" on your site and when they logged out or the session time out you would then store that information.
I do believe on a site you can use cPanel and get over all statistics about your site, but not what individuals do.
Lets see how you would "i want to take that text value and store it in the database along side a timestamp." from post one.
User goes to your site and get a login screen. He/she logs in giving you his user name and password in a form that is passed to a php program that cleans the variable and looks into the database to see if he is registered. At the point if he is registered you can make a DB entree with his name and time. Simple. Also at this time you can set the session variable for her name so you can follow her on your site.
When things are over you can get the variable
foreach ($_SESSION as $key=>$val)
echo $key." ".$val."<br/>";
Or instead of echoing them put them into an array and then put the array into the db.