Results 1 to 4 of 4

Thread: sessions

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Resolved sessions

    Ok i've got a big deadline to meet and i didnt wnat to run into problems like this

    Ok all my code has been fine so far for my UserCP they log in and i assign a string to a session variable name 'myid' then each page checks the string corrosponds to what it should be, eg here is my log in script

    PHP Code:
    Session_Start();

    if (
    $username==$dbuser and $mpassword==$dbpassword)
    {
            
    $_SESSION['myid'] = "ymn2prymn2pr";
            
    header('Location: /admin.html');
            exit();
    }
    else
    {
            
    session_destroy();
            unset(
    $_SESSION);
            
    header('Location: /badpw.html');
            exit();


    I've missed off the db connection bit and removed the url but it all works fine because it goes to the admin page.

    in the admin page there is this code

    PHP Code:
    session_start();

    if (
    $_SESSION['myid'] != "ymn2prymn2pr")
    {
            
    session_destroy();
            unset(
    $_SESSION);
            
    header('Location: /hckattempt.html');
            exit();  

    as you see it checks to make sure the varible should be the string. now then the thing is when i try and echo the session variable 'myid' its empty.

    Is this a server error? Or is my login code incorrect?

    Pino
    Last edited by Pino; Feb 20th, 2005 at 03:56 PM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: sessions

    Ok, after clearing all my cache and stuff it worked...

    This is leading me to think that my log out code is messing things up

    PHP Code:
    <?php
    Session_Start
    ();

    session_destroy();
    unset(
    $_SESSION);

    header('Location: /loggedOut.php');
    exit();  
    ?>
    Thats the first script thats called

    PHP Code:
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    type="text/css">

    <
    script>

    function 
    clnow()

    {

    top.location.href "/logIn.html";

    }

    </
    script>

    </
    head>
    <
    body bgcolor="#000000" text="#FFFFFF" onload="clnow()"
    Then the above script is called, whast going wrong ?

  3. #3
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: sessions

    I this could be a logical error rather than a server error. Try introducing some debugging echo statements to check that the program flow is as intended.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: sessions

    Quote Originally Posted by visualAd
    I this could be a logical error rather than a server error. Try introducing some debugging echo statements to check that the program flow is as intended.
    Ok, it seemed to be a problem with the java script to exit... and it seems to be fixed. Thanks for the help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width