Jump to content


Help With Sessions Code

  • Please log in to reply
1 reply to this topic

#1 Unholy Prayer

Unholy Prayer
  • Members
  • PipPipPip
  • Advanced Member
  • 166 posts

Posted 04 October 2006 - 11:11 PM

Ok, I have my sessions code for my user authentication script, but I want to display the user's username once they are logged in.  I also want the links in a certain part of the page to change once they are logged in.  Here is my coding:

//check cookie
 if ($_SESSION['logged_in'] != 1 && isset($_COOKIE['login_cookie'])) {
    list($user, $pass) = explode('[]', $_COOKIE['login_cookie']);
     $qu = mysql_query("SELECT `user_password` FROM `members` WHERE `username` = '".addslashes($user)."'");
    if (mysql_num_rows($qu) == 1) {
        $passw = mysql_fetch_object($qu);
        if ($passw->user_password == $pass) {
          $_SESSION['logged_in'] = 1;
           $_SESSION['username'] = $user;
            $_SESSION['password'] = $pass;

if(!isset($_SESSION['username']) && !isset($_SESSION['password'])) {
   $_SESSION['logged_in'] = 0;
   $user = "Guest"; 

How would I do this?

#2 Kelset

  • Members
  • PipPip
  • Member
  • 29 posts

Posted 04 October 2006 - 11:38 PM

Not really sure for I have not done a whole lot with sessions. Displaying the user name on the page would not be to hard
since you already put it into the session. Just call it up from the session() where you want to use it. As for you link changing
problem I would make set a session to a link type. Once they log in I would check to see what link type they are using
and use PHP to display a menu of links from a include file.

Not sure if I made any sense there or not... I guess it would depend on how many different link set ups you have.
I hope this helped in some weird way.


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users