I have problem in printing the values of session when I put the print statement directly after the session_start() function it prints but if I put it lower in the code it does not print !
<?php session_start();print_r($_SESSION);
?>
<? include("db1.php");
define('WP_USE_THEMES', false);
require('blog/wp-blog-header.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title><? print_r($_SESSION['title']);?></title>
</head>
Unless you have short tags enabled you will need to keep using <?php
and ?>
all through your code.
<head>
<title><?php print_r($_SESSION['title']);?></title>
</head>
Edit: See this for further information on short tags
Edit Two: Can you verify the output of the print_r()
? Are you certain that the element is called 'title'
?
Edit Three: Seeing as I am about to head off to bed, here is a workaround at least:
<?php
session_start();
print_r($_SESSION);
// As it works here...
$myTitle=$_SESSION['title'];
?>
<head>
<title><?php echo $title;?></title>
</head>
What is printed out instead of the $_SESSION variable content? What if you use var_dump($_SESSION);? why are you using print_r to print a title tag? why not to use (if you have to use session as a container) echo $_SESSION['title']; ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.