vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How can I use sessions for this? (https://vborg.vbsupport.ru/showthread.php?t=59185)

AutomatikStudio 12-15-2003 04:50 PM

How can I use sessions for this?
 
Okay...I've got a game on my site that you would usually have to log in to...but what I want to do is make it so that once you've logged in to the forum you don't have to log into the game. I'm assuming you would use sessions but not sure how vBulletin's sessions work. Any input would rock face.

Forum: http://www.banterboards.com
Game: http://monsterslayer.banterboards.com

WannabeArtist 12-17-2003 10:33 PM

Well, this *should* be pretty easy. Just do a session_start() at the beginning of your game's php script and match the session_id() with the session data in your forum's database.
I can only tell you how that should work on vB 3.0 as I don't have 2.3.3 set up.
Code:

<? php
session_start();
require('path_to_forum/includes/config.php');
mysql_connect($servername, $dbusername, $dbpassword);
mysql_select_db($dbname);
$userdata=mysql_query("SELECT * FROM session LEFT JOIN user ON(session.userid=user.userid) WHERE sessionhash='".session_id."'");
if ($userdata=mysql_fetch_array($userdata)) {
    your game's php code where $userdata got all the info stored in an array
} else {
    display login box
}
?>

Well, as long as your users go to the forum first and only after that to the ok, this should work. However, if they close all their browser windows and then go to that site it probably won't recognize them. Hope I was able to help out a bit, and good luck.

BTW, I *think* that simply including the global.php file of the forum does all of this and more automatically. If I'm able to remember correctly the data would be accessed through the array $bbuserinfo


All times are GMT. The time now is 11:14 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00921 seconds
  • Memory Usage 1,711KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete