PDA

View Full Version : Sessions


Karkar
06-18-2007, 05:18 AM
I want every user who joins my site to have their own section that only they can see. Does this mean I have to assign a different session to each user so that different info is grabbed from the DB for every user.

davidj
06-18-2007, 05:34 AM
yes

just use a user_id (auto increment) and assign it when your logging in

you can use that user_id to query the database every time you need data

Karkar
06-18-2007, 05:58 AM
Ok, i think i know what you mean, I'm just not exactly sure what to do:

<?php
session_start();

require_once("connections/connection.php");
include("includes/securityclient.php");

$idclient = $_SESSION['idclient'];

/////////////////////
$query = sprintf("SELECT * FROM users where field_id='$idclient' ");
$result = @mysql_query($query);
$rowAccount = @mysql_fetch_array($result);
/////////////////////

///////////////////////////////////////////////
$query = sprintf("SELECT * FROM usr_upd");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
///////////////////////////////////////////////
?>

What is happening in that script is allowing access to a members' page that only people who login can see. As I stated before I want every member to see their own page, and as you can see in the script that's not happening.

So this session is 'idclient' and it's getting the data from the usr_upd table on the db.

$query = sprintf("SELECT * FROM users where field_id='$idclient' ");

field_id is my autoincriment. Above is getting info from a table of users. field_id = $idclient - isn't that saying that whatever the field_id AI is will decide on which session is going to load - but in this case, the idclient session is the only one the script knows about.

This is so confuding :|

davidj
06-18-2007, 06:09 AM
ok you would have a contents table in your db. The contents table has its own id but also has a user_id which links that content to the user_id in the user table on a join.

when you login just set a $_SESSION['user_id'] with the user id of that person logging in. Carry that around your application until you need to render the user page where you can query the contents table and display the information

Karkar
06-18-2007, 06:13 AM
ok. I will try to figure this out from here with what you've told me and see how far i can get before i'll need your help again hehe :)

ty

Karkar
06-18-2007, 08:56 AM
100 posts. Yay! :-)

davidj
06-18-2007, 08:57 AM
thats cheating

davidj
06-18-2007, 08:58 AM
your not allowed to post shite

davidj
06-18-2007, 08:58 AM
to improve

davidj
06-18-2007, 08:58 AM
your post count

Andromeda
06-18-2007, 09:03 AM
LOL! Can we all play?

Andromeda
06-18-2007, 09:04 AM
Only another 41 posts to go

Andromeda
06-18-2007, 09:05 AM
100 posts. Yay! :-)
Congratulations :smile:

Karkar
06-18-2007, 09:05 AM
lol! Sorry sir! Won't happen again, sir! :P

Karkar
06-18-2007, 09:05 AM
Congratulations :smile:

Thankyou, thankyou. Atleast someone is happy for me

davidj
06-18-2007, 01:28 PM
your bloody doing it again

davidj
06-18-2007, 01:28 PM
stop it now

Karkar
06-18-2007, 10:46 PM
ok. Consider it stopped

domedia
06-19-2007, 12:24 AM
Why don't you guys just hit the edit key on your post instead of posting a one liner all the time, *cough*dj*cough*

Karkar
06-19-2007, 11:24 AM
whah?? i didn't know you could do that??

Time to edit

Karkar
06-19-2007, 11:25 AM
it doesn't work!!

Andromeda
06-19-2007, 07:31 PM
You should be able to edit your post up to about 30 minutes after you originally posted it I think. The edit button at the bottom right of the box that your post appears in.

davidj
06-20-2007, 06:06 AM
i think it was a wind up