Jump to content

Archived

This topic is now archived and is closed to further replies.

Unholy Prayer

Help With Sessions Code

Recommended Posts

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:

[code]
//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";
}[/code]

How would I do this?

Share this post


Link to post
Share on other sites
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.


Cheers!
Stephen

Share this post


Link to post
Share on other sites

×

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.