Ryan Bayne
asked on
Word Press destroys session data
Hey all
Below you will see a block of code which uses Word Press header functions. Couple of days back I realised that after the WP code was parsed my applications SESSION data was being erased. You will see my quick fix to avoid headaches and I would like to know a better way of getting around the problem
Thats not all!
The second block of code shows how I include two seperate files to make the page (2 column page). The right side attempts to include "pages_right/.php" so the variable $adminpage is not longer set and I do not get an error saying so and should if its really not defined!
I removed the WP code and both pages showed fine so its the original problem causing this also. But I can't fix it the same way! The other problem with SESSIONS allowed me to define variables in the same file as where the word press code is but its not allowing me to reverse it and put the value into a SESSION or simply do $adminpage = $adminpage!
I'm confused about the whole thing now! Before I could say Word Press was erasing SESSIONS but now I don't know what its doing.
Any help would get this development moving again thanks
Below you will see a block of code which uses Word Press header functions. Couple of days back I realised that after the WP code was parsed my applications SESSION data was being erased. You will see my quick fix to avoid headaches and I would like to know a better way of getting around the problem
Thats not all!
The second block of code shows how I include two seperate files to make the page (2 column page). The right side attempts to include "pages_right/.php" so the variable $adminpage is not longer set and I do not get an error saying so and should if its really not defined!
I removed the WP code and both pages showed fine so its the original problem causing this also. But I can't fix it the same way! The other problem with SESSIONS allowed me to define variables in the same file as where the word press code is but its not allowing me to reverse it and put the value into a SESSION or simply do $adminpage = $adminpage!
I'm confused about the whole thing now! Before I could say Word Press was erasing SESSIONS but now I don't know what its doing.
Any help would get this development moving again thanks
<?php
# PUT LOGIN SESSIONS IN VARIABLE AS WORD PRESS DELETES THEM
if(isset($_SESSION['auth'])){$session_auth = $_SESSION['auth'];}
if(isset($_SESSION['member'])){$session_member = $_SESSION['member'];}
# INCLUDE WORDPRESS HEADER
define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php');
query_posts('cat=74&showposts=10'); while (have_posts()) : the_post(); ?>
<p><strong><?php the_title();?></strong>
<?php the_excerpt(); ?></p>
<p class="dotLine1"><a href="http://www.webtechglobal.co.uk/index.php?page=df/blog&blogframe=archives/<?php echo $wp_id;?>" title="View more" target="_blank" class="viewMore">View more</a></p>
<?php endwhile;
# WORDPRESS DELETES SESSIONS - RESET THEM HERE
if(isset($session_auth)){$_SESSION['auth'] = $session_auth;}
if(isset($session_member)){$_SESSION['member'] = $session_member;}
?>
SECOND BLOCK
else{include('pages_left/'.$adminpage.'.php'); if(!isset($adminpage)){echo "WP DESTROYS DATA";}require('pages_right/'.$adminpage.'.php');}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad to help! Thanks for the points, ~Ray
ASKER
Thanks for that code