Jump to content

Help With Sessions Code


Unholy Prayer

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?
Link to comment
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
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.