Session ID and Storing in Mysql

Hi, I’m new to PHP. i wondering if i’m able to store my session id in mysql db? i know how to get my session id from.
[php]$a = session_id();
if(empty($a)) session_start();
echo "SID: ".SID."
session_id(): ".session_id()."
COOKIE: ".$_COOKIE[“PHPSESSID”];[/php]

but i dunno know how to store the session id in mysql db. kindly show me the way ?

thanks for your help in advance

  1. make a connection the database
    [php]
    //only changes to the information of the array below
    $database = array (“localhost”,“db_user”,“db_password”,“db_name”);

$conn = mysql_connect($database[0],$database[1],$database[2]) or die(“cant open the connection
”.mysql_error());
mysql_select_db($database[3]) or die(“could not select db
”.mysql_error());
[/php]

  1. run an insert query
    [php]
    mysql_query(“INSERT INTO tbl_name(field_name) VALUES (’$a’)”) or die(“Error in the query
    ”.mysql_error());
    [/php]

  2. close the database connection
    [php]
    mysl_close($conn) or die(mysql_error());
    [/php]

  3. [size=10pt]Good Luck[/size]

Sponsor our Newsletter | Privacy Policy | Terms of Service