WordPress.org

Ready to get started?Download WordPress

Forums

Creating a session variable from user ID - problem? (3 posts)

  1. ruraldev
    Member
    Posted 4 years ago #

    I am trying to create a session variable for use in an iframe page.

    I thought this would work but I was wrong, can anyone help please?

    The following code is in a non wordpress page.

    <?php
    session_start();
    include '../wp-config.php';
    ?>
    <?php
    $_SESSION['UserID'];
    get_currentuserinfo();
    echo $_SESSION['UserID']->ID;
    ?>
    <table width="100%"  border="0" cellspacing="0" cellpadding="0" height="500">
      <tr>
        <td valign="top">
    <table width="100%"  border="0" cellspacing="0" cellpadding="0" height="20">
      <tr bgcolor="#D0C1F7" >
        <td width="13%"></td>
        <td width="78%" class="sitename">Cycling routes supplied by </td>
        <td width="9%" align="right" valign="bottom">
    	<?php if($_SESSION['UserID']!=NULL){?>
    	<a href="home.php">Home</a>|&nbsp;|<a href="logout.php">Logout</a>
    	<?php } ?></td>
      </tr>
    </table>
    <?php echo $_SESSION['UserID'];?>
  2. dolby_uk
    Member
    Posted 4 years ago #

    Unfortunately you cannot use $_SESSION in WordPress. See: http://blog.ginchen.de/en/2008/08/15/session-variablen-in-wordpress/

  3. Ginchen
    Member
    Posted 4 years ago #

    Why is everybody here telling people that you can't use session vars with WordPress, while referring to my blog post in which I describe how you actually CAN use them ...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.