jaykappy Posted April 3, 2013 Share Posted April 3, 2013 Trying to use sessions...seems to be working alright but can grab it and display in page. I first send user to login screen (testindex.php) ... Where they login in or register a new account I then bring them to a page that displays data in a table. (MainPageIndex.php) On this page the user has the ability to update these records When they update them I am grabbing the Session user for this update with this ':ModifiedBy' => $_SESSION['user']['username'], and placing it in the Modified field for update....this is working fine... so it seems that I can grab the Session username from this second page ALTHOUGH At the same time on this page i am trying to display the Session username with NO success.....anyone have any thoughts....I can post more code if need be... <h2> <span tabindex="-1"><?php echo htmlentities($_SESSION['user']['username'], ENT_QUOTES, 'UTF-8'); ?></span> <span id="headerLoginUser" tabindex="-1">Welcome: </span> </h2> Link to comment https://forums.phpfreaks.com/topic/276481-using-sessions/ Share on other sites More sharing options...
jaykappy Posted April 3, 2013 Author Share Posted April 3, 2013 BUt I place this in the MainPageInxdex.php and I get the redirection....so it tells me that at this point it does not have to Session user???? But I call the update form from this page....I dont see anywhere in update .php page where I am asking for the Session user name... confused here.... <?php if(empty($_SESSION['user'])) { header("Location: login.php"); die("Redirecting to login.php"); }else{ echo "Full ".$_SESSION['user']; } ?> Link to comment https://forums.phpfreaks.com/topic/276481-using-sessions/#findComment-1422641 Share on other sites More sharing options...
jaykappy Posted April 3, 2013 Author Share Posted April 3, 2013 Let me step back: I have a (Testindex.php) page Asks for a login I then jump to a portal page (after verification of the user name) that has links to other websites that we have made........ON THIS PAGE i can return the session users name (Login.php) I click a link on this portal page that goes to a web page that I created that displays records from a table... .......I want to display the Session user name in this page. with no success .......The confusing part is that from this page I am popping up a modify form to modify the records in the table and using ':ModifiedBy' => $_SESSION['user']['username'], to update the user name with the Session Username...why cant I display the username on this page but use it in the update query update.php page that is called from the Form submit on the page. Link to comment https://forums.phpfreaks.com/topic/276481-using-sessions/#findComment-1422646 Share on other sites More sharing options...
jaykappy Posted April 3, 2013 Author Share Posted April 3, 2013 Think I got it....be right back Link to comment https://forums.phpfreaks.com/topic/276481-using-sessions/#findComment-1422675 Share on other sites More sharing options...
jaykappy Posted April 3, 2013 Author Share Posted April 3, 2013 I added a little piece of code that starts the session....this fixed everything... <?php // Start Session session_start(); ?> This is what did it.... Link to comment https://forums.phpfreaks.com/topic/276481-using-sessions/#findComment-1422676 Share on other sites More sharing options...
taichimasta Posted June 16, 2013 Share Posted June 16, 2013 Sorry I'm going to be "that guy" but WOW. session_start(); is the basic function when using sessions , whatever page you want your user/client info to be remembered on put that and your golden. now you just have to make sure you secure it from any from of exploit. Good luck! Admin or Jaykappy can mark this as SOLVED! Link to comment https://forums.phpfreaks.com/topic/276481-using-sessions/#findComment-1436201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.