Questions: Which event starts first and sessions

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Sniper_E
Registered User
Posts: 1126
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Questions: Which event starts first and sessions

Post by Sniper_E »

When a user connects to your forum I need to know which event start first.

I use these two events in the listener.php (mobiledevice extension)

public function session_create_after($event)
public function page_header($event)

Q1: Does a visitor start a session when they first connect or is that only ran when a member logs in?

IF so...

Q2: When a visitor comes to your site will it run the page_header or the session_create_after first?
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Questions: Which event starts first and sessions

Post by david63 »

It is my understanding that all visitors create a session and that the session is one of the first actions to take place - however whether this happens on every visit or not I am not sure - for example if there is already a session for that IP address would that event be triggered?

Can you not set up some debug code to test which event is triggered first in varying circumstances?
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
kasimi
Former Team Member
Posts: 4900
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Questions: Which event starts first and sessions

Post by kasimi »

Using terminology from the code, each request starts a session but doesn't necessarily create one. Creating only happens on the first request, when there's no valid $session_id in the cookie or URL.

I think the best option for you is core.user_setup(_after) which is called on every request for both guests and members.

core.page_header is the last of the mentioned events to get triggered, if it's triggered at all. For example, AJAX requests might not render the page header, and in the ACP core.adm_page_header is called instead.
User avatar
Sniper_E
Registered User
Posts: 1126
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Questions: Which event starts first and sessions

Post by Sniper_E »

OK got it. Thanks guys.

I switched to using the page_header event to update the user's device_name column in the db... and then using the session_create_after event to log the mobile device name. With this order of events I can see where part of my problem may be.

I'll work with that and check into using the core.user_setup(_after) also. Appreciate it guys!
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco
Contact:

Re: Questions: Which event starts first and sessions

Post by 3Di »

just use core.user_setup_after to update the user's device_name column in the db.

And core.page_header_after to assign variables to the template - over all (like function page_header did at those times ;) )

Right or wrong is the same concept as per mine IPCF ext.

Plus you might want to use - if not already done - other events for viewtopic and so on.
Like core.viewtopic_cache_user_data and core.viewtopic_modify_post_row
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
Sniper_E
Registered User
Posts: 1126
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Questions: Which event starts first and sessions

Post by Sniper_E »

Image
Image . -.. / .... ..- -- .--. .... .-. . -.--
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!

:!: Sniper_E Styles | phpbbmodders :!:
Post Reply

Return to “Extension Writers Discussion”