vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Using sessions or cookies from vBulletin (https://vborg.vbsupport.ru/showthread.php?t=286983)

josh_krz 08-23-2012 02:43 PM

Using sessions or cookies from vBulletin
 
I was just wondering if it is possible to use cookies or sessions from vBulletin on a non vB page on my website.

I would like to disable a webpage to people in a certain usergroup, is this possible?

Ideally I would like to use template variables with my vB header etc. but every solution I come across just seems so overly complicated.

Thank you.

kh99 08-23-2012 02:49 PM

You'd have to do something like this: https://vborg.vbsupport.ru/showthread.php?t=228112 . If your non-vb pages are php, then you might be able to include global.php without doing everything that that article shows (if you just wanted the user's group, for instance). But if you mean html pages, then you'd have to create a php page like is shown in that article, and either put in php code to read your html file and return it (after checking the user's group), or else put your html in a template. (I hope this makes some sense - please ask for clarification if it doesn't :) )

josh_krz 08-23-2012 02:58 PM

That article is great, could you elaborate more on using global.php please?

So like, when I include that file, do I just use the template variables as normal or is there a different way of using them?

Thank you.

kh99 08-23-2012 03:06 PM

Quote:

Originally Posted by josh_krz (Post 2359345)
That article is great, could you elaborate more on using global.php please?

If you did nothing other than include the vbulletin global.php, you'd be able to use $vbulletin to do things like check if the user is logged in or which group they're in. There are a couple of issues: one is that the current directory needs to be the forum directory (the one global.php is in) before you include it, so if your script is in another directory you need to chdir() to the vb directory first. Also, the user will only appear as logged in if the vb cookies are sent, so if your script is outside the vb directory, the vb cookie path needs to be set to '/' or else it will always look like the user is a guest.


Quote:

So like, when I include that file, do I just use the template variables as normal or is there a different way of using them?
I'm not quite sure I follow. I guess it depends on which variables you want. They may be available just by including global.php, or you might need to find the code that calculates them. I'm also not sure if you mean you want to use templates, or if you just want the info in the variables. If you want to use templates, you probably should just use what's shown in that article as a guide.

josh_krz 08-23-2012 03:12 PM

Sorry I explained it in a bad way.

What I mean is will I be able to use <vb:if condition="$vboptions['enablesearches']"> inside that PHP file?

Or do you use it like so;

if ($vboptions['enablesearches'] == true;){
//Show search bar;
}

kh99 08-23-2012 03:15 PM

You could use this:

Code:

if ($vbulletin->options['enablesearches'] == true){
//Show search bar;
}


To be honest I'm not sure about $vboptions - it's a shortcut variable equivalent to $vbulletin->options that's created for use in templates, but I'm not sure if it's defined outside of a template.

josh_krz 08-23-2012 03:19 PM

Ok thanks, Ill have a go at that and see what's what.

kh99 08-23-2012 03:23 PM

Yeah, my "edit" above (which I removed) may have been wrong - I'm not sure if you can use $vboptions or not - I'd have to do a test (or maybe someone else will know).


All times are GMT. The time now is 05:06 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.00972 seconds
  • Memory Usage 1,727KB
  • 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
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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