------------------ session.reg ------------------ ---------------- other pages start basically same as admin page except like this: ---------------- [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => <40daa691@212.67.96.135> [ref] => [htmlstate] => on_nl2br [postusername] => Wayne... [ip] => w.robson@onetel [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> > mysql_free_result($users); >?> > } else { > include('login.php'); >} >$_SESSION['login']; >//no else as yet only put in if needed >?> >------------------ >session.reg >------------------ >//initiate variables and sessions >$user = 'username'; >$pw = 'thepassword'; >// check password and name against one to admitted > if((isset($_POST['name']) && isset($_POST['pass'])) && (($_POST['name'] == >$user))&& ($_POST['pass'] == $pw)) { > //start session for admitted access > $_SESSION['login']='admit'; > } else { > //start session for denied access > $_SESSION['deny']='deny'; > } >?> >---------------- >other pages start basically same as admin page except like this: >---------------- >if(!session_id()){ > session_start(); > header("Cache-control: private"); //IE 6 Fix >} >if (isset($_SESSION['login'])) { > require_once('Connections/connection.php'); //this is just a simple mysql >connection string >///etc etc..... >mysql_free_result($news); >?> > } else { > include('login.php'); >} >?> > >[/quote] [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => <40daa691@212.67.96.135> [htmlstate] => on_nl2br [postusername] => eclipsboi [ip] => eclipsboi@hotma [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 6 [islastshown] => 1 [isfirstshown] => [attachments] => [allattachments] => ) --> session losing on server but not on localhost...globals turned off? --help - PHP Development

session losing on server but not on localhost...globals turned off? --help - PHP Development

I have been having loads of probs with a login system I've been writing..it works here on my test machine but the moment I upload it to the server it throws me back to the login page. the sernario is this: 1- login form passes to admihn page where I include the page to create a session if the correct name and pass have been entered. 2- then the admin page checks if the correct session exsists and if it does allows access if not throws back to the login page. 3- all the pages that are linked from the ...

  1. #1

    Default session losing on server but not on localhost...globals turned off? --help

    I have been having loads of probs with a login system I've been writing..it
    works here on my test machine but the moment I upload it to the server it
    throws me back to the login page. the sernario is this:
    1- login form passes to admihn page where I include the page to create a
    session if the correct name and pass have been entered.
    2- then the admin page checks if the correct session exsists and if it does
    allows access if not throws back to the login page.
    3- all the pages that are linked from the admin page have the same basic
    idea (only not creating the session just checking for its existance. I'm no
    expert but my feeling is its something along the lines of globals being
    turned off. Is there a way round this when checking? its as if the session
    is distroyed or does not exist after going to the admin page.
    I'm using the same version of php on both server and local machine. the 1st
    part of code is below... I cant see it being a syntax error or it wouldn't
    work on this machine. I'm intersted in anyway round this, as I am not
    advanced as such pointing me in the right direction would be a great help
    thanks in advance.

    Wayne..

    --------------
    login passes form feild names pass to admin
    ---------------

    ---------------
    admin.php
    ---------------
    <?
    if(!session_id()){
    session_start();
    header("Cache-control: private"); //IE 6 Fix
    }
    // if not work use this
    //session_start();
    //header("Cache-control: private"); //IE 6 Fix
    require_once('includes/session_reg.php');

    if (isset($_SESSION['login'])) {
    require_once('Connections/connection.php'); //this is just a simple mysql
    connection string
    ?>
    <!-- rest of doc that is secure here -->
    <?php
    mysql_free_result($users);
    ?>
    <?
    } else {
    include('login.php');
    }
    $_SESSION['login'];
    //no else as yet only put in if needed
    ?>
    ------------------
    session.reg
    ------------------
    <?
    //initiate variables and sessions
    $user = 'username';
    $pw = 'thepassword';
    // check password and name against one to admitted
    if((isset($_POST['name']) && isset($_POST['pass'])) && (($_POST['name'] ==
    $user))&& ($_POST['pass'] == $pw)) {
    //start session for admitted access
    $_SESSION['login']='admit';
    } else {
    //start session for denied access
    $_SESSION['deny']='deny';
    }
    ?>
    ----------------
    other pages start basically same as admin page except like this:
    ----------------
    <?
    if(!session_id()){
    session_start();
    header("Cache-control: private"); //IE 6 Fix
    }
    if (isset($_SESSION['login'])) {
    require_once('Connections/connection.php'); //this is just a simple mysql
    connection string
    ///etc etc.....
    <?php
    mysql_free_result($news);
    ?>
    <?
    } else {
    include('login.php');
    }
    ?>



    Wayne... Guest

  2. #2

    Default Re: session losing on server but not on localhost...globals turned off? --help

    *** Wayne... wrote/escribió (Thu, 24 Jun 2004 11:01:47 +0100):
    > if(!session_id()){
    > session_start();
    > header("Cache-control: private"); //IE 6 Fix
    > }
    I maybe wrong but... Here you say that you only want to use stored session
    data if there isn't a session ID (i.e., it there isn't any data stored!).

    Probably, your test server has session.auto_start set to on (so this code
    doesn't affect 'cos session data is loaded anyway) while your production
    server has session.auto_start set to off.


    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --
    Alvaro G Vicario Guest

  3. #3

    Default Re: session losing on server but not on localhost...globals turned off? --help

    I stuck that line is as a test really, it still doesn't work without it....
    thanks for the quick reply

    Wayne...

    "Alvaro G Vicario" <alvaro_QUITAR_REMOVEtelecomputeronline.com> wrote in
    message news:y5j6jayclwsf.1lvclczeacei4$.dlg40tude.net...
    > *** Wayne... wrote/escribió (Thu, 24 Jun 2004 11:01:47 +0100):
    > > if(!session_id()){
    > > session_start();
    > > header("Cache-control: private"); //IE 6 Fix
    > > }
    >
    > I maybe wrong but... Here you say that you only want to use stored session
    > data if there isn't a session ID (i.e., it there isn't any data stored!).
    >
    > Probably, your test server has session.auto_start set to on (so this code
    > doesn't affect 'cos session data is loaded anyway) while your production
    > server has session.auto_start set to off.
    >
    >
    > --
    > --
    > -- Álvaro G. Vicario - Burgos, Spain
    > --

    Wayne... Guest

  4. #4

    Default Re: session losing on server but not on localhost...globals turned off? --help

    *** Wayne... wrote/escribió (Thu, 24 Jun 2004 11:31:45 +0100):
    > I stuck that line is as a test really, it still doesn't work without it....
    > thanks for the quick reply
    What happens when you just remove the if()?

    session_start();

    --
    --
    -- Álvaro G. Vicario - Burgos, Spain
    --
    Alvaro G Vicario Guest

  5. #5

    Default Re: session losing on server but not on localhost...globals turned off? --help

    if your on about the check if $_SESSION['login'] login exists, then access
    is allowed to everyone, if your on about the other if, it throws me back to
    the login as usual, I also tried a standard well known bit of session
    learning code as an experiment and the same problem occurs. any idea what
    would be the cause [so I can try and get this sorted at the hosting end]?

    Wayne...


    Wayne... Guest

  6. #6

    Default Re: session losing on server but not on localhost...globals turned off? --help

    You have to remember to call session_start() on every new page you're
    going to use the session. As for register_globals being off, that's
    ok--just use the superglobal $_SESSION to access your session
    variables. Why it works on one and not the other; I could only venture
    that there _is_ something different between the two. Other than that,
    I don't know--I personally hate PHP sessions and have sworn them off
    [almost] completely. ^_^

    On Thu, 24 Jun 2004 11:01:47 +0100, "Wayne..."
    <w.robsononeteldsl.net> wrote:
    >I have been having loads of probs with a login system I've been writing..it
    >works here on my test machine but the moment I upload it to the server it
    >throws me back to the login page. the sernario is this:
    >1- login form passes to admihn page where I include the page to create a
    >session if the correct name and pass have been entered.
    >2- then the admin page checks if the correct session exsists and if it does
    >allows access if not throws back to the login page.
    >3- all the pages that are linked from the admin page have the same basic
    >idea (only not creating the session just checking for its existance. I'm no
    >expert but my feeling is its something along the lines of globals being
    >turned off. Is there a way round this when checking? its as if the session
    >is distroyed or does not exist after going to the admin page.
    >I'm using the same version of php on both server and local machine. the 1st
    >part of code is below... I cant see it being a syntax error or it wouldn't
    >work on this machine. I'm intersted in anyway round this, as I am not
    >advanced as such pointing me in the right direction would be a great help
    >thanks in advance.
    >
    >Wayne..
    >
    >--------------
    >login passes form feild names pass to admin
    >---------------
    >
    >---------------
    >admin.php
    >---------------
    ><?
    >if(!session_id()){
    > session_start();
    > header("Cache-control: private"); //IE 6 Fix
    >}
    >// if not work use this
    >//session_start();
    >//header("Cache-control: private"); //IE 6 Fix
    >require_once('includes/session_reg.php');
    >
    >if (isset($_SESSION['login'])) {
    > require_once('Connections/connection.php'); //this is just a simple mysql
    >connection string
    >?>
    ><!-- rest of doc that is secure here -->
    > <?php
    >mysql_free_result($users);
    >?>
    ><?
    > } else {
    > include('login.php');
    >}
    >$_SESSION['login'];
    >//no else as yet only put in if needed
    >?>
    >------------------
    >session.reg
    >------------------
    ><?
    >//initiate variables and sessions
    >$user = 'username';
    >$pw = 'thepassword';
    >// check password and name against one to admitted
    > if((isset($_POST['name']) && isset($_POST['pass'])) && (($_POST['name'] ==
    >$user))&& ($_POST['pass'] == $pw)) {
    > //start session for admitted access
    > $_SESSION['login']='admit';
    > } else {
    > //start session for denied access
    > $_SESSION['deny']='deny';
    > }
    >?>
    >----------------
    >other pages start basically same as admin page except like this:
    >----------------
    ><?
    >if(!session_id()){
    > session_start();
    > header("Cache-control: private"); //IE 6 Fix
    >}
    >if (isset($_SESSION['login'])) {
    > require_once('Connections/connection.php'); //this is just a simple mysql
    >connection string
    >///etc etc.....
    ><?php
    >mysql_free_result($news);
    >?>
    ><?
    > } else {
    > include('login.php');
    >}
    >?>
    >
    >
    eclipsboi Guest

Similar Threads

  1. Problems with session on my localhost
    By RHO in forum PHP Development
    Replies: 2
    Last Post: June 26th, 06:26 PM
  2. Losing session on xp ie6
    By babyeatingreptile in forum Coldfusion - Getting Started
    Replies: 1
    Last Post: March 21st, 09:10 PM
  3. losing session
    By babyeatingreptile in forum Macromedia ColdFusion
    Replies: 0
    Last Post: March 21st, 09:07 PM
  4. Session problems with register globals enabled
    By Manu J in forum PHP Development
    Replies: 1
    Last Post: October 20th, 11:55 AM
  5. losing a session?
    By Gerard L Petersen in forum PHP Development
    Replies: 1
    Last Post: August 19th, 05:05 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139