SitePoint Sponsor |
|
User Tag List
Results 1 to 7 of 7
Thread: How do I read from a cookie?
-
Apr 16, 2001, 09:03 #1
I am using vBulletin, and would like to know how to read the cookie that is set when my users login, I want to display their name on pages outside of the forums, and will soon be implementing more that will be dependent on this.
-
Apr 16, 2001, 12:18 #2
- Join Date
- Mar 2001
- Posts
- 3,537
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi,
What is the cookie's name?
-
Apr 16, 2001, 12:40 #3
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The value you're looking for lies in the $bbuserid variable. You should be able to access it at any point within any PHP script running on the same domain as your copy of vBulletin.
This variable, however, only contains the user's ID number, and not their username. You'll need to query the database to extract the name. You would do so like this (if I remember vB's table structure correctly):
SELECT username FROM user WHERE userid='$bbuserid'
Good luck.
-
Apr 17, 2001, 10:35 #4
So there is no way to avoid querying the database?
I must query the database then....that is gonna slow my server down significantly, would it be wise to have vB store the user's name in the cookie? Would this be a potential security issue? I can't see how it would be, but I am very protective of my users, since most of them are minors. What would you reccommend, I don't think I would have problems altering the script, the question is wether it would be wise or not.
-
Apr 17, 2001, 11:06 #5
- Join Date
- Feb 2001
- Location
- Melbourne Australia
- Posts
- 6,282
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
I cannot see how it would slow down your server significantly. There are hundreds and hundreds of mySQL queries [i am exxagerating] happening in vBulletin, and if there was one query per page on the rest of your site it definately would not hurt.
Last edited by mmj; Apr 17, 2001 at 11:08.
[mmj] My magic jigsaw
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The Bit Depth Blog · Twitter · Contact me
Neon Javascript Framework · Jokes · Android stuff
-
Apr 17, 2001, 11:30 #6
- Join Date
- Aug 1999
- Location
- Pittsburgh, PA, USA
- Posts
- 3,910
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I don't think it's worthwhile to edit the script. As mmj said, if your site is receiving so much traffic that one query per page load will make a large difference, then you've got bigger problems.
-
Apr 17, 2001, 17:26 #7
ok thanks for the input
Bookmarks