Marcos01 Posted October 15, 2008 Share Posted October 15, 2008 Hello, How do I display the session id? And how do I store it a database? This is the code i have so far: session_start(); $bedrijfsnaam = $_POST['companyname']; $naam = $_POST['name']; $email = $_POST['email']; $query ="INSERT INTO formusers (sessionid, companyname, name, email) values('{$sessionid}','{$companyname}', '{$name},'{$email}')"; $result = mysql_query($query, $connection); if ($result){ echo "data added"; }else{ echo "data has not been added to database"; echo 'mysql_error()'; } Quote Link to comment https://forums.phpfreaks.com/topic/128524-solved-display-session-id-and-store-it-in-database/ Share on other sites More sharing options...
waynew Posted October 15, 2008 Share Posted October 15, 2008 session_id(); Quote Link to comment https://forums.phpfreaks.com/topic/128524-solved-display-session-id-and-store-it-in-database/#findComment-666072 Share on other sites More sharing options...
MadTechie Posted October 15, 2008 Share Posted October 15, 2008 <?php session_start(); $bedrijfsnaam = $_POST['companyname']; $naam = $_POST['name']; $email = $_POST['email']; $sessionid = session_id(); //<--ADD $query ="INSERT INTO formusers (sessionid, companyname, name, email) values('{$sessionid}','{$companyname}', '{$name},'{$email}')"; $result = mysql_query($query, $connection); if ($result){ echo "data added"; }else{ echo "data has not been added to database"; echo 'mysql_error()'; } ?> EDIT: ahh too slow Quote Link to comment https://forums.phpfreaks.com/topic/128524-solved-display-session-id-and-store-it-in-database/#findComment-666074 Share on other sites More sharing options...
GKWelding Posted October 15, 2008 Share Posted October 15, 2008 after session_start(); you need to add $sessionid=session_id(); This will populate your $sessionid variable with the current session id as determined by session_id(). Quote Link to comment https://forums.phpfreaks.com/topic/128524-solved-display-session-id-and-store-it-in-database/#findComment-666075 Share on other sites More sharing options...
Marcos01 Posted October 16, 2008 Author Share Posted October 16, 2008 Thanks all It worked! Quote Link to comment https://forums.phpfreaks.com/topic/128524-solved-display-session-id-and-store-it-in-database/#findComment-666894 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.