vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   One time hook per visit? (https://vborg.vbsupport.ru/showthread.php?t=197186)

JamesAB 11-25-2008 04:59 AM

One time hook per visit?
 
Is there a hook that is called once when a user first logs in or when they return to the forum and they remain logged in because they have the "Remember Me" box ticked?

I'm looking at the login hooks, but I'm not sure what happens if the user has ticked the "Remember Me" box.

Would any of the login hooks still get called if they aren't typing in their username/password?

Basically all I need is a hook that is only called once per visit.

Thanks for your help,
James

ReCom 11-25-2008 05:35 AM

I'm guessing that it must be one of those login_* hooks ...

JamesAB 12-02-2008 10:34 PM

As far as I can tell, the login hooks are only called when the member actually enters their username & password to login, but not if they are a returning visitor who had the "Remember Me" box ticked.

Anyone have any ideas on this?

Thanks,
James

Guest190829 12-02-2008 10:41 PM

You could use a global hook. Even though it is called on every page, you can use a conditional to only execute your code once per visit. You'll probably find a solution using cookies. :)

JamesAB 12-03-2008 03:54 AM

Quote:

Originally Posted by Danny.VBT (Post 1677383)
You could use a global hook. Even though it is called on every page, you can use a conditional to only execute your code once per visit. You'll probably find a solution using cookies. :)

Thanks Danny.VBT.

I worked out a cookie solution with the global_start hook, comparing TIMENOW to the time I set in the cookie. If more than an hour has passed since the cookie was set, I run my code.

Code:

$recountcookie = COOKIE_PREFIX . 'recount';
$recountcookietime = TIMENOW;

$vbulletin->input->clean_gpc('c', $recountcookie, 'TYPE_INT');

if ($vbulletin->GPC["$recountcookie"] <= ($recountcookietime - 3600))
{
    //Code to do my processing here
    //and then set a new cookie
    vbsetcookie('recount', $recountcookietime);
}

I also started looking at the article [How-To] Extend and use the Session Table Effectively

Which method would use fewer resources on a busy forum, cookies or sessions?

Thanks,
James


All times are GMT. The time now is 12:09 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.00916 seconds
  • Memory Usage 1,720KB
  • 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)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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