Working with session and post form variables

Discussion forum for Extension Writers regarding Extension Development.
MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Working with session and post form variables

Post by MKULTRA »

I have been attempting to work in a mod to eliminate bot registrations in 3.1 and am completely confused at this point. I cannot figure out how to retain session variables and check on post data in the ucp_registration.php file.

My session variables are not saving for the next page reload and I neither have I found a way to read the post from the session variables. I am trying use random names for my form elements (I have that portion working, which is one of several phases I am attempting to accomplish in a multi-pronged approach), but I cannot do anything with it at this point. I tried using both the $request->variable() and request_var() function as well, but nothing is ever returned with that either and even when I do get a return how then do I access its data when using dynamic names stored in the session? For example, in the past I accomplished this using: $_POST[$_SESSION['USERNAME']].

Noting that phpBB 3.1 seems to kill and deny any and all attempts at using $_SESSION and $_POST, et al. It seems finding away around this is beyond my novice knowledge.
Last edited by Oyabun1 on Mon Apr 20, 2015 10:16 pm, edited 1 time in total.
Reason: Moved from 3.1.x Support forum

User avatar
Lumpy Burgertushie
Registered User
Posts: 67754
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Working with session and post form variables

Post by Lumpy Burgertushie »

you eleminate bot registrations the same way as always. you use a good question in the Q&A captcha and you are done.
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?

MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Re: Working with session and post form variables

Post by MKULTRA »

I personally, do not like that method, using questions can be confusing and/or irritating for users. I am wanting the process to be handled mostly behind the scenes.

User avatar
Lumpy Burgertushie
Registered User
Posts: 67754
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: Working with session and post form variables

Post by Lumpy Burgertushie »

how are you going to determine who is a bot and who is not?

oh well, I can't really help you with this so I won't clutter up your topic.

sorry,
robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If nobody is in the forest, does a tree really fall?

MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Re: Working with session and post form variables

Post by MKULTRA »

The mod will also include a honey-trap, a version of the new No-Captcha-ReCapatcha jQuery script, a micro-timing check on submissions, and will just divert to the normal thank you page upon failures or a flooding-lockout page once a threshold has been reached on repeated page reloads.

User avatar
Wolfsblvt
Registered User
Posts: 634
Joined: Sun Oct 26, 2014 9:12 pm
Location: Solingen, Germany
Contact:

Re: Working with session and post form variables

Post by Wolfsblvt »

Why do you want to use session variables? phpBB has it's own session handling built-in so I am quite sure it won't work.

You should stick to request->variable() and form vars I would guess, or use cookies if data needs to be saved for further calls.

Also note: phpBB 3.1 uses extension. All things that you modify on the core should be done via extensions.
MODs are not allowed for 3.1 anymore.
If you have a specific extension request and you are willing to pay for, you can write me a PM.
My extensions (Trending: @Mention SystemAdvanced PollsUser Online Time)

»Du kamst zu uns. Deine Stimme kam. Du zeigtest uns die Sterne. Sie funkelten. Wir konnten sehen.«

MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Re: Working with session and post form variables

Post by MKULTRA »

Is there any instruction for any of this, Googling only queues stuff from 2007-2009, so far that I have found?

For example, how do you get data from a session variable or session array using the request method? Such as storing for data dynamically in a session to use it for checking on form data, e.g., $_POST[$_SESSION['USERNAME']]?

How do these extensions work, do you have to first create and install an entire extension prior to working with it, meaning you have to be a PHP and SQL expert in order to work on phpBB anymore? I am thinking you cannot work on a script with extensions on the fly, yes?

User avatar
Mick
Support Team Member
Support Team Member
Posts: 22443
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Working with session and post form variables

Post by Mick »

MKULTRA wrote:Is there any instruction for any of this
And a little search found this: Writing Extensions.
"The more connected we get the more alone we become" - Kyle Broflovski©

MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Re: Working with session and post form variables

Post by MKULTRA »

Thank you. Though what about working with $_POST and retrieving $_SESSION variables, etc? This seems to have me completely stuck spinning circles at this point. Surely, phpBB 3.1 has some other way to save, modify, and read session data, yes?

In my testing, I could access POST data, but I could never get my SESSION variables to retain its set value.

User avatar
Wolfsblvt
Registered User
Posts: 634
Joined: Sun Oct 26, 2014 9:12 pm
Location: Solingen, Germany
Contact:

Re: Working with session and post form variables

Post by Wolfsblvt »

As I said already, phpBB has it's own session variables.

And superglobals ($_POST, $_SESSION, $_SERVER, etc) aren't allowed to use.

As I've asked already, what do you need this for? Why do you need to use $_SESSION?
What's your goal, what are you doing?
With more information we may could help.
If you have a specific extension request and you are willing to pay for, you can write me a PM.
My extensions (Trending: @Mention SystemAdvanced PollsUser Online Time)

»Du kamst zu uns. Deine Stimme kam. Du zeigtest uns die Sterne. Sie funkelten. Wir konnten sehen.«

MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Re: Working with session and post form variables

Post by MKULTRA »

OK, and how does one use them in phpBB 3.1? Because, I haven't the foggiest clue, I had tried several Google searches, but everything is from many years ago so that is of no help for 3.1. Is there a walk through manual or is this some secret that nobody can speak of, but only vaguely mention?

I need to use these because I need to store data in the session for security or verification purposes; also I need to use this for because I had integrated phpBB 3.0 into my main Webpage (external to phpBB, carrying over the session and selected Db information), allowing users to login and logout and view new posts within selected forums, but now I am receiving errors as of my upgrade, so far I have been unable to resolve them and nothing works on the page any longer. Due to:
Warning: Cannot modify header information - headers already sent by (output started at /.../index.phtml:20) in /.../includes/functions.php on line 2562

Fatal error: Call to a member function sql_close() on a non-object in /.../includes/functions.php on line 5439

MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Re: Working with session and post form variables

Post by MKULTRA »

Is this part of the code used to setup sessions? If so is there a naming class specific for general sessions as well?

Setup:
$user_row = array(
'username' => $data['username'],
...

Retrieve:

$test=$user_row['username'];

User avatar
Wolfsblvt
Registered User
Posts: 634
Joined: Sun Oct 26, 2014 9:12 pm
Location: Solingen, Germany
Contact:

Re: Working with session and post form variables

Post by Wolfsblvt »

You should probably read all those guides for new extensions then.

[HowTo] Convert 3.0 MOD into 3.1 Extension
"Hello World!" - Extension
Writing Extensions

And I think there are even more.
You have to understand the basics for extension development, otherwise it will be difficult to code stuff for 3.1.x.
If you have a specific extension request and you are willing to pay for, you can write me a PM.
My extensions (Trending: @Mention SystemAdvanced PollsUser Online Time)

»Du kamst zu uns. Deine Stimme kam. Du zeigtest uns die Sterne. Sie funkelten. Wir konnten sehen.«

MKULTRA
Registered User
Posts: 188
Joined: Tue Oct 16, 2007 12:07 pm
Contact:

Re: Working with session and post form variables

Post by MKULTRA »

So then are these the correct methods for checking and saving form data in a session?

To check if form element has been set: $request->is_set_post('...');

To set a session variable: $config->set('...','');

(I read those articles linked above and they really just go over the basics of doing a rudimentary extension and converting from MOD to EXT, but does not really touch about how to work with sessions and form data in phpBB 3.1.)

User avatar
Wolfsblvt
Registered User
Posts: 634
Joined: Sun Oct 26, 2014 9:12 pm
Location: Solingen, Germany
Contact:

Re: Working with session and post form variables

Post by Wolfsblvt »

There isn't a real good explenation for what you want. But request object is pretty self-explaining with its functions.

$config->set() is wrong though. It sets the global config for phpBB and has nothing to do with users and sessions.

I will ask again:
What do you want to achieve with using those php session things?
If you have a specific extension request and you are willing to pay for, you can write me a PM.
My extensions (Trending: @Mention SystemAdvanced PollsUser Online Time)

»Du kamst zu uns. Deine Stimme kam. Du zeigtest uns die Sterne. Sie funkelten. Wir konnten sehen.«

Post Reply

Return to “Extension Writers Discussion”