Jump to content


Photo
- - - - -

Session variable not passing from one hook to the other


Best Answer trevorcr , 11 January 2013 - 04:18 PM

Hi,  I have this working now.  The session variable cleanup, unset $_SESSION[variable] was causing updates by the hook at pagelines_before_html to not take effect.  You can monitor SESSION updates by reading the session file at session.save_path or /var/lib/php/session/sess_{session id}.  That will lead you to where the culprit is.

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 trevorcr

trevorcr

    Member

  • Members
  • 24 posts
  • LocationSan Jose, CA
  • Framework Version:2.4.5
  • Country: Country Flag

Posted 10 January 2013 - 11:10 PM

I have two hooks on the same page at "pagelines_before_html" and "pagelines_loop_before_post_content" arranged as follows;

hook @ pagelines_before_html:

Please Login or Register to see this Hidden Content

 

hook @ pagelines_loop_before_post_content:

Please Login or Register to see this Hidden Content

 

Web page;

Please Login or Register to see this Hidden Content

 

The problem is nothing gets printed even though the message is setup correctly in the first hook.  Is there something I am missing to get SESSION variables to work across hooks?

 

-Trevor



#2 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 10 January 2013 - 11:31 PM

Can you use a pastebin for your code, its pretty much unreadable above,

 

Please Login or Register to see this Hidden Content



#3 trevorcr

trevorcr

    Member

  • Members
  • 24 posts
  • LocationSan Jose, CA
  • Framework Version:2.4.5
  • Country: Country Flag

Posted 11 January 2013 - 12:10 AM

Yes, I pasted the code to the paste bin.



#4 Simon_P

Simon_P

    Messer

  • Administrators



  • 8388607 posts
  • LocationDevon
  • Framework Version:2.1.1
  • Country: Country Flag

Posted 11 January 2013 - 12:26 AM

Hmm, well....

 

1st, wordpress does not use sessions, not sure why your trying to use them either. Nothing wrong with using global variables seeing as the page is only rendered once the variable can be globalized and shared between 2 hooks on the same page.

 

2nd your using raw sql stuff there, thats very dodgy. You should try and use the built in wordpress database api to sanatize all that stuff.



#5 trevorcr

trevorcr

    Member

  • Members
  • 24 posts
  • LocationSan Jose, CA
  • Framework Version:2.4.5
  • Country: Country Flag

Posted 11 January 2013 - 04:18 PM   Best Answer

Hi,  I have this working now.  The session variable cleanup, unset $_SESSION[variable] was causing updates by the hook at pagelines_before_html to not take effect.  You can monitor SESSION updates by reading the session file at session.save_path or /var/lib/php/session/sess_{session id}.  That will lead you to where the culprit is.