Jump to content

Using Sessions


jaykappy

Recommended Posts

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
Share on other sites

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']; 
    } 
?>
Edited by jaykappy
Link to comment
Share on other sites

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
Share on other sites

  • 2 months later...

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!

  Edited by taichimasta
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.