+ Reply to Thread
Results 1 to 3 of 3

Thread: session variable not working

  1. #1
    krahny's Avatar
    krahny is offline x10Hosting Member krahny is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    25

    Exclamation session variable not working

    I have a session variable set on one page, and I know it gets set because it works for that page, but whaen I go to a new page, it seems as though it's not set.

    Here's the code that sets the variable:

    session_start();
    $_SESSION['logging']=$_POST['username'];

    Here's the code that's on both of the pages, but only writes the cookie on the first one:

    if(isset($_SESSION['logging'])){
    echo $_SESSION['logging'];
    }

    Could someone please help?

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: session variable not working

    Do you have session_start() on the second page?
    Are you sure nothing has been sent to the browser before you call session_start() on the second page?
    Nothing is always absolutely so.

  3. #3
    krahny's Avatar
    krahny is offline x10Hosting Member krahny is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    25

    Thumbs up Re: session variable not working

    No, I forgot to put session_start() on the second page. Thanks!

+ Reply to Thread

Similar Threads

  1. Subdomain not working
    By trogenhorse in forum Free Hosting
    Replies: 5
    Last Post: 04-28-2008, 10:57 AM
  2. ads are not working
    By rayminator in forum Free Hosting
    Replies: 5
    Last Post: 03-23-2008, 09:07 PM
  3. Replies: 1
    Last Post: 03-15-2008, 04:54 PM
  4. Could not use SESSION in PHP to store arrary?
    By muimse in forum Free Hosting
    Replies: 0
    Last Post: 03-12-2008, 01:32 PM
  5. Site not working
    By Immortal in forum Free Hosting
    Replies: 1
    Last Post: 09-10-2005, 02:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers