XF 2.1 Get a new session var and have it everywhere

Robert9

Well-known member
I have no idea about sessions now and before i start watching the files i would like to know if there is anything build in in XF2 to use that.

The idea is that you call the forum with any possible adress, add ?var=123 and have this var whereever i need it.

Is there anything build in here, please?
 
You're looking for something like
PHP:
$this->filter('var_name', 'str')
inside controller or controller plugin.
 
So controller is something that is done always and everywhere i guess?
So i have to extend it and save this value somehwere, but where?
I have no idea about sessions, this is a value that is written/read with every page again?
Or is it saved in the browser as {a session}, as cookie, both?
 
And is this the right place also to pass a var from one page to another?

Example:
I add a new post and there i have a new form field "var"; i write something into this field and send it.
Now i want to have {{var}} in the shown thread again.
 
It makes sense to save this value just in a global?
$GLOBALS['var'] = $this->filter('var', 'str');

And i get it from something extended that is always called?
 
I need the value till the person comes to the "upgrade page";
there i have to add it to the payment form and sent it to the payment provider; he will do the rest.


OR

i add an unvisible custom user field and save it there.
This means i have to hold/carry the var till the registration form




Real life:

You have an advert to be a super hero; i click it and i come to the forum with

xenhero.com/somethread?var=hero123 (or any other page)

i register and "hero123" is saved in my custom user field

some days later i want to buy an upgrade, the payment form shows "affiliate=hero123"; the rest is done by the payment provider.



Real life 2:

I just safe the user_id of the refering user with a link or banner;

now i have this user_id in my custom user field

I add a page and show the top list of users refering users

I add promotion stuff for 10, 100, 1000
 
Top Bottom