vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Adding value to database when successfully logged in (https://vborg.vbsupport.ru/showthread.php?t=286589)

Sangheili 08-13-2012 05:57 AM

Adding value to database when successfully logged in
 
I've been trying to play around with adding a value to the database whenever a successful login is made by the user, I assume it's meant to go in functions_login?

I would ideally like to add a value to the 'loggedin' column of the users row in the database but only when they successfully login. Could someone give me an idea of how to structure this code please?

kh99 08-13-2012 02:17 PM

If you mean you want to save data whenever the user enters their password (and not when they're using "remember me"), then you could use the hook login_verify_success (in function verify_authentication(), in includes/functions_login.php around line 201), or the hook login_process (function_login.php, line 362).

If you want to do it whenever a new session is created (by entering the password or by having a "remember me" cookie), then I think you could use hook global_shutdown (in function exec_shut_down(), in includes/functions.php around line 8043). If you look at the code below where that hook is called you'll see where it checks to see if the user just logged in. I think if you did this:

Code:

if (is_object($vbulletin->session) AND $vbulletin->session->vars['loggedin'] == 1 AND $vbulletin->session->created)
{
  // just created new session for logged in user
}


The login_process hook doesn't seem to be called when logging in with a cookie (as happens when "remember me" was previously checked).


All times are GMT. The time now is 01:05 AM.

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.00957 seconds
  • Memory Usage 1,708KB
  • 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