Session variables disappear?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jim_73_mk1
Forum Newbie
Posts: 15
Joined: Mon Nov 24, 2003 9:42 pm
Contact:

Session variables disappear?

Post by jim_73_mk1 »

I'm not sure why but my session variables are vanishing! I've got this code snippet below and the signup() function uses the session to add information to the database. When the page is redirected by the header call all the session variables are gone. Why?

Thanks,
Jim

Code: Select all

<?php
if (!signup()) {
  session_destroy;
  echo '<p align="center" class="warning">
    There was a problem processing your signup.  Please try again later.';
} else {
  header("Location:http://somplace.php");
}
?>
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

Post by harsha »

cannot use session_register when you are using $_SESSION and viceversa

if so the unset($_SESSION['name']) ;

and don;t unset($_SESSION); it is meaningless;
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Put

Code: Select all

header("Location:http://somplace.php?".SID);
and make sure

Code: Select all

session_start();
is at the top of http://somplace.php other wise your session will end.
Post Reply