Title: Creating a session variable from user ID &#8211; problem?
Last modified: August 19, 2016

---

# Creating a session variable from user ID – problem?

 *  [ruraldev](https://wordpress.org/support/users/ruraldev/)
 * (@ruraldev)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/creating-a-session-variable-from-user-id-problem/)
 * 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'];?>
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [dolby_uk](https://wordpress.org/support/users/dolby_uk/)
 * (@dolby_uk)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/creating-a-session-variable-from-user-id-problem/#post-1433993)
 * Unfortunately you cannot use $_SESSION in WordPress. See: [http://blog.ginchen.de/en/2008/08/15/session-variablen-in-wordpress/](http://blog.ginchen.de/en/2008/08/15/session-variablen-in-wordpress/)
 *  [Ginchen](https://wordpress.org/support/users/ginchen/)
 * (@ginchen)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/creating-a-session-variable-from-user-id-problem/#post-1434101)
 * 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 …

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Creating a session variable from user ID – problem?’ is closed to new
replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 3 participants
 * Last reply from: [Ginchen](https://wordpress.org/support/users/ginchen/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/creating-a-session-variable-from-user-id-problem/#post-1434101)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
