Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-12-29 22:08:28

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 106
Website

Session is reset when using php include

My problem is quite complicated to explain because there is a shopping system involved for which I am trying to use textpattern as a seperated CMS.
It almost works but there is a problem with the session.

So I try to break it down to the facts that are relevant.

In my textpattern “page” I include some php file via <txp:php> include ‘somefile.php’; </txp:php>.

Via print_r($_SESSION); in somefile.php I ouptut the session.

If I call somefile.php directly in the browser it shows the session. Even if I reload this site.
If I call my textpattern URL it shows me the correct session, but after a reload it is all reset.

Any chance to say something about this problem without going more into detail?
Is there some natural behavior of textpattern when using an include in the pages that might cause that problem?

My Textpattern version is 4.8
Would be great if someone had an idea.

Offline

#2 2019-12-29 22:31:04

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,637
Website

Re: Session is reset when using php include

As far as I recall, we don’t touch sessions in core, besides during /setup. Are you running any plugins such as:

  • MLP (I presume not, since I don’t think it works in 4.8)
  • yab_shop

Both of those mess with session variables and I’ve known them to cause weird behaviour like you mention.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2019-12-29 22:40:51

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 106
Website

Re: Session is reset when using php include

Thanks Stef for your quick opinion about it.
I just disabled all plugins. Same result.

Offline

#4 2020-01-02 16:22:46

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 106
Website

Re: Session is reset when using php include

I solved this problem now, by including the metioned somefile.php into the index.php of textpattern directly.
I still do not really know if it is has more to do with the shopping system or more with textpattern, but the session does not get lost now.

Last edited by demoncleaner (2020-01-02 16:23:15)

Offline

#5 2020-01-03 13:17:13

etc
Developer
Registered: 2010-11-11
Posts: 3,768
Website

Re: Session is reset when using php include

demoncleaner wrote #320792:

I solved this problem now, by including the metioned somefile.php into the index.php of textpattern directly.

Dunno what happens, I have no problems with sessions when including via <txp:php />. Anyway, if it works now, you could try setting

$txpcfg['pre_publish_script'] = 'path/to/somefile.php';

in config.php rather than modifying index.php.

Offline

#6 2020-01-03 13:49:03

demoncleaner
Plugin Author
From: Germany
Registered: 2008-06-29
Posts: 106
Website

Re: Session is reset when using php include

Magic! And much better than my approach. Thx a lot.

Offline

Board footer

Powered by FluxBB