Search
Left Quote    Maybe this world is another planet's Hell.
- Aldous Huxley    
Right Quote
 
[login] | [Register]
Forum Index » PHP and mySQL » Viewing Topic and Replies
Post Reply


        Viewing Topic: Member ID in Session
  This user is offline  BoricuaLayz
  Subject: "Member ID in Session" Posted: @ 10:08 pm on Jun 30 2007   
Member #: 356
Rank: User - (30)
Since: 06/25/07
Posts: 44
From: Florida

If i wanted a members ID stored in the session when they log in how would i go about that


    Viewed: 10,733 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Member ID in Session" Posted: @ 4:47 pm on Jul 01 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

see if this is what you're looking for: PHP.NET/SESSIO N_ID




-bs0d | AllSyntax.com

    Viewed: 10,719 Times | Reply to This | To top
  This user is offline  BoricuaLayz
  Subject: "re: Member ID in Session" Posted: @ 3:50 am on Jul 02 2007    
Member #: 356
Rank: User - (30)
Since: 06/25/07
Posts: 44
From: Florida

no i mean how can i make it so that the users's id

the one that is manually given to them when they register

can also be stored in the session with the username and password

because i am scripting a PM system (Private Messaging System) for my member area and it needs the id of the logged in member to check if he has any messages and to send a message



Edited at 03:52:59 am on 07/02/07


    Viewed: 10,699 Times | Reply to This | To top
  This user is offline  WintersDance
  Subject: "re: Member ID in Session" Posted: @ 1:37 pm on Jul 02 2007    

Member #: 353
Rank: User - (27)
Since: 06/19/07
Posts: 36
From: California

maybe just query the member id number by matching where 'username' = $_SESSION['use rname'] and set the result as a varible that can now be called up by your PM script.




wintersdance |     Viewed: 10,689 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Member ID in Session" Posted: @ 6:10 pm on Jul 02 2007    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

Well, i have id for the members table that is auto_increment. Assign that value to $_SESSION['use r_id'] in your page header and it'll be available throughout the website.




-bs0d | AllSyntax.com

    Viewed: 10,683 Times | Reply to This | To top
  This user is offline  BoricuaLayz
  Subject: "re: Member ID in Session" Posted: @ 6:18 pm on Jul 02 2007    
Member #: 356
Rank: User - (30)
Since: 06/25/07
Posts: 44
From: Florida

so you are telling me to edit this code


Code:

if ($_SESSION['lo gged_in'] != 1 && isset($_COOKIE[ 'login_cookie '])) {
list($user, $pass) = explode('[]', $_COOKIE['logi n_cookie']);
$qu = mysql_query(&q uot;SELECT `user_password` FROM `members` WHERE `username` = '".addsl ashes($user).& quot;'";
if (mysql_num_rows ($qu) == 1) {
$passw = mysql_fetch_obj ect($qu);
if ($passw->use r_password == $pass){
$_SESSION['log ged_in'] = 1;
$_SESSION['use rname'] = $user;
$_SESSION['pas sword'] = $pass;
}
}
}



Edited at 06:28:52 pm on 07/02/07


    Viewed: 10,679 Times | Reply to This | To top
  This user is offline  BoricuaLayz
  Subject: "re: Member ID in Session" Posted: @ 7:09 pm on Jul 02 2007    
Member #: 356
Rank: User - (30)
Since: 06/25/07
Posts: 44
From: Florida

Would this work?

$username = $_SESSION['use rname'];
$q = "SELECT id FROM members WHERE CONVERT( `members`.`user name` USING utf8 ) = '$username' LIMIT 1;";
$result = @mysql_query($q );
$row = mysql_fetch_arr ay($result);
$member_id = $row['id'];




    Viewed: 10,673 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2018; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank