Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2011-07-05 08:44:30
- leafy_loader
- Member
- Registered: 2008-09-25
- Posts: 96
Setting a SESSION variable in txp
I have an include with my own php code which, once certain criteria are met, sets a session variable (an array). When I navigate away from the page to another page on the same site I don’t seem to be able to access the session variable.
Does txp unset custom session variables?
Offline
Re: Setting a SESSION variable in txp
leafy_loader wrote:
Does txp unset custom session variables?
Nope. Not that I’m aware of. As long as your code runs on every page and has session_start()
somewhere near the top of the page then you’ll be good to go.
But bear in mind that some plugins use sessions (yab_shop and MLP spring to mind) so if you have either of those installed they might be hijacking your custom session.
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 2011-07-05 09:15:55
- leafy_loader
- Member
- Registered: 2008-09-25
- Posts: 96
Re: Setting a SESSION variable in txp
OK that works thanks.
I’d made the assumption that txp calls session_start() so didn’t think I would have to.
Offline
Re: Setting a SESSION variable in txp
leafy_loader wrote:
I’d made the assumption that txp calls session_start() so didn’t think I would have to.
Nope, Textpattern itself doesn’t use sessions. In case some plugin does, you can make sure to not to call session_start() twice by checking if $_SESSION is set. I.e.
if(!isset($_SESSION))
session_start();
Offline
Pages: 1