The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
(temporarily) save data to cookie or session
Heya!
I built a plugin with a search in it, which I want to paginate. The easiest way in my mind was to save the search term(s) either into a session or a cookie and then, when page two is requested, do the search query again. Now I can't seem to be able to access either cookies or session. Tried using $_SESSION or $_COOKIE or vbsetsession() but to little avail it did not work Any recommendations on how to properly do this? Any help is really appreciated ps: with "not working" I mean, that I can write to either, but after reloading the page, the information is no longer saved |
#2
|
|||
|
|||
A better way is to keep the search term in the URL (a $_GET parameter). Have you considered that?
|
#3
|
|||
|
|||
Yep I have, but it is multiple keywords / checkboxes and I don't want to "clutter up" the URL that way
|
#4
|
|||
|
|||
You could serialize those variables and put them in the URL in 1 parameter.
You could also base64_encode it. |
#5
|
|||
|
|||
yep I know I could do this, but don't want to
That would be the last resort; second to last would be to resend the form on every page change - but still, the question is: how can I use vbulletin sessions or cookies |
#6
|
|||
|
|||
Alright well in order to set a session variable, you can use $vbulletin->session->set('key', 'value');
For cookies you want to use vbsetcookie('key', 'value'); |
#7
|
|||
|
|||
Thanks Dave!
How would I read them? Just using $_COOKIE / $_SESSION? |
#8
|
|||
|
|||
I believe you can use $vbulletin->session->vars['key'] to access the session variable.
You can just use $_COOKIE['key'] to access the cookie value. |
#9
|
||||
|
||||
This is a vB page? Then do it the proper vB way. https://vborg.vbsupport.ru/showthread.php?t=221670
|
#10
|
|||
|
|||
thanks for your help!!
Quote:
I can save to the session, but refreshing the page yields no data. Cookies are not working at all :/ Quote:
I _don't_ want to have $_GET params; the page you linked to has actually no keywords or params to be searching for. Or am I missing something? If I get it to work, I would still like to know how to save data to the session / cookie |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|