Sessions not working

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Sessions not working

    Hello

    We have a asp.net solution which consists of 5 projects. Up until a few
    days ago, when we deployed the solution on our webserver all was fine. We
    were copying the dll's and aspx pages to the appropriate folders.

    However for the past couple of days the deployed site will no longer work as
    no session variables are being created or updated. We have set a number of
    session variables in the application start, but these are not being created.

    We have tried re-booting the server, and various IIS setups (it is IIS 5.0
    as far as I know). We have also set it up on a new webserver with no luck.

    We are out of ideas, and wondered if anyone else had an idea.

    Thanks in advance
    Helen.


    Helen G Guest

  2. Similar Questions and Discussions

    1. CGI::Sessions : Deleting expired sessions
      Hi, I use CGI::Sessions to save the sessions into MySQL. The problem is, if the user just close the browser windows without logging off, I can't...
    2. php4+apache1.3+xp with sessions not working...
      Please help. I seem to have a major problem with sessions on my setup. No simple example seems to work. Example below: page1.php: <?php //...
    3. Database sessions and file sessions
      Can database sessions and file system sessions co-exist on the same server. I have 2 applications that use sessions. One uses the standard php...
    4. [PHP] problem with sessions - IE working after session.use_trans_sid enabled.
      On 17 August 2003 12:38, anders thoresson wrote: Just a wild guess -- but has your IE got cookies blocked, whilst Opera is accepting them? ...
  3. #2

    Default Re: Sessions not working

    Helen,
    Did you install any anti-virus software? In particular, if the anti-virus software
    "touches" the web.config, your application will be restarted, and hence you will
    lose your session vars.

    If not, then take a look at the following MS KB search. There are a number
    of reasons why your application is losing Session state - depending on it's
    configuration.

    [url]http://support.microsoft.com/search/default.aspx?Catalog=LCID%3D1033%26CDID%3DEN-US-KB%26PRODLISTSRC%3DON&withinResults=&QuerySo[/url]
    urce=gASr_Query&Product=aspnet&Queryc=session&Quer y=session&KeywordType=ANY&maxResults=25&Titles=fal se&numDays=

    --

    Thanks,
    Carl Prothman
    Microsoft ASP.NET MVP
    [url]http://www.able-consulting.com[/url]


    "Helen G" <helen@pracctice.com> wrote
    > We have a asp.net solution which consists of 5 projects. Up until a few
    > days ago, when we deployed the solution on our webserver all was fine. We
    > were copying the dll's and aspx pages to the appropriate folders.
    >
    > However for the past couple of days the deployed site will no longer work as
    > no session variables are being created or updated. We have set a number of
    > session variables in the application start, but these are not being created.
    >
    > We have tried re-booting the server, and various IIS setups (it is IIS 5.0
    > as far as I know). We have also set it up on a new webserver with no luck.
    >
    > We are out of ideas, and wondered if anyone else had an idea.
    >
    > Thanks in advance
    > Helen.
    >
    >

    Carl Prothman [MVP] Guest

  4. #3

    Default Sessions not working

    After starting a session and assigning data to the session variable (ie.
    $_SESSION['username']), the variable only contains a value on the page the
    session was created on.

    For example, moderators on my site log into their accounts on a page called
    admin.php. Once the username/password have been matched against the values
    in the mysql database, I want to assign the username to
    $_SESSION['username'] so it's available on all pages.

    If I print out the contents of $_SESSION['username'] on admin.php right
    after they've logged in, it will display their username without problem, but
    once the user leaves admin.php, $_SESSION['username'] is blank.

    It doesn't seem to matter if I attach PHPSESSID=session_id() to the URL or
    not. $_SESSION['username'] is always blank once the user leaves the page
    where session_start() was originally called.

    Does anyone have any ideas on why this might be? Here are my hosts session
    settings from phpinfo() in case they're relevant:

    session.auto_start - Off
    session.cache_expire - 180
    session.cache_limiter - nocache
    session.cookie_domain - no value
    session.cookie_lifetime - 0
    session.cookie_path - /
    session.cookie_secure - Off
    session.entropy_file - no value
    session.entropy_length - 0
    session.gc_maxlifetime - 1440
    session.gc_probability - 1
    session.name - PHPSESSID
    session.referer_check - no value
    session.save_handler - files
    session.save_path - /tmp
    session.serialize_handler - php
    session.use_cookies - On
    session.use_trans_sid - 1

    I created a the directory /tmp on my webspace, but it didn't help at all.
    Any help here would be appreciated.

    Thanks
    Mark Liam


    Mark Guest

  5. #4

    Default Re: Sessions not working

    Mark,
    > ... once the user leaves the page where session_start() was originally
    called.

    When and where are you calling session_start() ?

    Just in the Admin.php file?

    -dn


    "Mark" <npspam@omas.com> wrote in message
    news:L8APb.53191$7JB1.9536@news04.bloor.is.net.cab le.rogers.com...
    > After starting a session and assigning data to the session variable (ie.
    > $_SESSION['username']), the variable only contains a value on the page the
    > session was created on.
    >
    > For example, moderators on my site log into their accounts on a page
    called
    > admin.php. Once the username/password have been matched against the
    values
    > in the mysql database, I want to assign the username to
    > $_SESSION['username'] so it's available on all pages.
    >
    > If I print out the contents of $_SESSION['username'] on admin.php right
    > after they've logged in, it will display their username without problem,
    but
    > once the user leaves admin.php, $_SESSION['username'] is blank.
    >
    > It doesn't seem to matter if I attach PHPSESSID=session_id() to the URL or
    > not. $_SESSION['username'] is always blank once the user leaves the page
    > where session_start() was originally called.
    >
    > Does anyone have any ideas on why this might be? Here are my hosts
    session
    > settings from phpinfo() in case they're relevant:
    >
    > session.auto_start - Off
    > session.cache_expire - 180
    > session.cache_limiter - nocache
    > session.cookie_domain - no value
    > session.cookie_lifetime - 0
    > session.cookie_path - /
    > session.cookie_secure - Off
    > session.entropy_file - no value
    > session.entropy_length - 0
    > session.gc_maxlifetime - 1440
    > session.gc_probability - 1
    > session.name - PHPSESSID
    > session.referer_check - no value
    > session.save_handler - files
    > session.save_path - /tmp
    > session.serialize_handler - php
    > session.use_cookies - On
    > session.use_trans_sid - 1
    >
    > I created a the directory /tmp on my webspace, but it didn't help at all.
    > Any help here would be appreciated.
    >
    > Thanks
    > Mark Liam
    >
    >

    Dung Nguyen Guest

  6. #5

    Default Re: Sessions not working

    It's being called only in the admin file, at the top of the page before the
    script outputs anything to the screen. The code I'm using is below
    (simplified). It starts a session in admin.php, sets $_SESSION['username']
    to "BLACK" and then provides a link to index.php. If I follow the link to
    index.php, which echos the contents of $_SESSION['username'] to the screen
    and nothing appears. Index.php does not call session_start again because
    I'm only using sessions for specific accounts and the code is set up to only
    start a session when a user logs in (only moderators are required to log in,
    anyone else can read/post without an account).

    <?php

    // CONNECT TO DATABASE

    $sq = mysql_connect("dbname", "dbuser", "dbpass")
    or die("Unable to connect to database: " . mysql_error() . "<BR>");

    mysql_select_db("dbname");

    // IF SUBMIT WAS PRESSED, VERIFY IDENTITY

    if ($_POST["submit"]) {

    // QUERY DATABASE FOR MATCHING USER/PASSWORD

    $result = mysql_query("SELECT * FROM users WHERE uname='$adminname' AND
    upass='$adminpass'")
    or die("Unable to query database: " . mysql_error() . "<BR>");

    if (mysql_num_rows($result) <= 0) {
    echo("<BR><CENTER><B>Invalid username/pasword combination. Click <A
    HREF=\"admin.php\">here</A> to try again.</B></CENTER><BR><BR><BR>");
    }

    // username & password match
    // begin session...

    else {

    session_start();

    $_SESSION['username'] = "BLACK";

    echo("Session id: " . session_id());
    echo("<A HREF=\"index.php\">Index</A>");

    }

    mysql_free_result($result);
    mysql_close($sq);
    include("incs/footer.php");
    exit();
    }

    ?>

    "Dung Nguyen" <dung@ucdavis.edu> wrote in message
    news:bumkdj$ric$1@woodrow.ucdavis.edu...
    > Mark,
    >
    > > ... once the user leaves the page where session_start() was originally
    > called.
    >
    > When and where are you calling session_start() ?
    >
    > Just in the Admin.php file?
    >
    > -dn
    >
    >
    > "Mark" <npspam@omas.com> wrote in message
    > news:L8APb.53191$7JB1.9536@news04.bloor.is.net.cab le.rogers.com...
    > > After starting a session and assigning data to the session variable (ie.
    > > $_SESSION['username']), the variable only contains a value on the page
    the
    > > session was created on.
    > >
    > > For example, moderators on my site log into their accounts on a page
    > called
    > > admin.php. Once the username/password have been matched against the
    > values
    > > in the mysql database, I want to assign the username to
    > > $_SESSION['username'] so it's available on all pages.
    > >
    > > If I print out the contents of $_SESSION['username'] on admin.php right
    > > after they've logged in, it will display their username without problem,
    > but
    > > once the user leaves admin.php, $_SESSION['username'] is blank.
    > >
    > > It doesn't seem to matter if I attach PHPSESSID=session_id() to the URL
    or
    > > not. $_SESSION['username'] is always blank once the user leaves the
    page
    > > where session_start() was originally called.
    > >
    > > Does anyone have any ideas on why this might be? Here are my hosts
    > session
    > > settings from phpinfo() in case they're relevant:
    > >
    > > session.auto_start - Off
    > > session.cache_expire - 180
    > > session.cache_limiter - nocache
    > > session.cookie_domain - no value
    > > session.cookie_lifetime - 0
    > > session.cookie_path - /
    > > session.cookie_secure - Off
    > > session.entropy_file - no value
    > > session.entropy_length - 0
    > > session.gc_maxlifetime - 1440
    > > session.gc_probability - 1
    > > session.name - PHPSESSID
    > > session.referer_check - no value
    > > session.save_handler - files
    > > session.save_path - /tmp
    > > session.serialize_handler - php
    > > session.use_cookies - On
    > > session.use_trans_sid - 1
    > >
    > > I created a the directory /tmp on my webspace, but it didn't help at
    all.
    > > Any help here would be appreciated.
    > >
    > > Thanks
    > > Mark Liam
    > >
    > >
    >
    >

    Mark Guest

  7. #6

    Default Re: Sessions not working

    Mark,

    Web servers are stateless machines. Each URL request, i.e. each page is its
    own entity. The idea behind session is to provide a mechanism for defining
    states. Having said that, the session_start() function called in admin.php
    is complete once PHP reaches the bottom of the page (admin.php). The
    session information would have been written out to a temporary file. The
    next page the user accesses, e.g. user.php knows nothing of your intention
    to use the previous states unless you tell it too, i.e. via a call to
    session_start().

    So at the top of every page you need to call session_start() so that it is
    able to access the information stored in the session.

    Hope that helps.

    -DN


    "Mark" <npspam@omas.com> wrote in message
    news:uGAPb.53685$7JB1.45230@news04.bloor.is.net.ca ble.rogers.com...
    > It's being called only in the admin file, at the top of the page before
    the
    > script outputs anything to the screen. The code I'm using is below
    > (simplified). It starts a session in admin.php, sets
    $_SESSION['username']
    > to "BLACK" and then provides a link to index.php. If I follow the link
    to
    > index.php, which echos the contents of $_SESSION['username'] to the screen
    > and nothing appears. Index.php does not call session_start again because
    > I'm only using sessions for specific accounts and the code is set up to
    only
    > start a session when a user logs in (only moderators are required to log
    in,
    > anyone else can read/post without an account).
    >
    > <?php
    >
    > // CONNECT TO DATABASE
    >
    > $sq = mysql_connect("dbname", "dbuser", "dbpass")
    > or die("Unable to connect to database: " . mysql_error() . "<BR>");
    >
    > mysql_select_db("dbname");
    >
    > // IF SUBMIT WAS PRESSED, VERIFY IDENTITY
    >
    > if ($_POST["submit"]) {
    >
    > // QUERY DATABASE FOR MATCHING USER/PASSWORD
    >
    > $result = mysql_query("SELECT * FROM users WHERE uname='$adminname' AND
    > upass='$adminpass'")
    > or die("Unable to query database: " . mysql_error() . "<BR>");
    >
    > if (mysql_num_rows($result) <= 0) {
    > echo("<BR><CENTER><B>Invalid username/pasword combination. Click <A
    > HREF=\"admin.php\">here</A> to try again.</B></CENTER><BR><BR><BR>");
    > }
    >
    > // username & password match
    > // begin session...
    >
    > else {
    >
    > session_start();
    >
    > $_SESSION['username'] = "BLACK";
    >
    > echo("Session id: " . session_id());
    > echo("<A HREF=\"index.php\">Index</A>");
    >
    > }
    >
    > mysql_free_result($result);
    > mysql_close($sq);
    > include("incs/footer.php");
    > exit();
    > }
    >
    > ?>
    >
    > "Dung Nguyen" <dung@ucdavis.edu> wrote in message
    > news:bumkdj$ric$1@woodrow.ucdavis.edu...
    > > Mark,
    > >
    > > > ... once the user leaves the page where session_start() was originally
    > > called.
    > >
    > > When and where are you calling session_start() ?
    > >
    > > Just in the Admin.php file?
    > >
    > > -dn
    > >
    > >
    > > "Mark" <npspam@omas.com> wrote in message
    > > news:L8APb.53191$7JB1.9536@news04.bloor.is.net.cab le.rogers.com...
    > > > After starting a session and assigning data to the session variable
    (ie.
    > > > $_SESSION['username']), the variable only contains a value on the page
    > the
    > > > session was created on.
    > > >
    > > > For example, moderators on my site log into their accounts on a page
    > > called
    > > > admin.php. Once the username/password have been matched against the
    > > values
    > > > in the mysql database, I want to assign the username to
    > > > $_SESSION['username'] so it's available on all pages.
    > > >
    > > > If I print out the contents of $_SESSION['username'] on admin.php
    right
    > > > after they've logged in, it will display their username without
    problem,
    > > but
    > > > once the user leaves admin.php, $_SESSION['username'] is blank.
    > > >
    > > > It doesn't seem to matter if I attach PHPSESSID=session_id() to the
    URL
    > or
    > > > not. $_SESSION['username'] is always blank once the user leaves the
    > page
    > > > where session_start() was originally called.
    > > >
    > > > Does anyone have any ideas on why this might be? Here are my hosts
    > > session
    > > > settings from phpinfo() in case they're relevant:
    > > >
    > > > session.auto_start - Off
    > > > session.cache_expire - 180
    > > > session.cache_limiter - nocache
    > > > session.cookie_domain - no value
    > > > session.cookie_lifetime - 0
    > > > session.cookie_path - /
    > > > session.cookie_secure - Off
    > > > session.entropy_file - no value
    > > > session.entropy_length - 0
    > > > session.gc_maxlifetime - 1440
    > > > session.gc_probability - 1
    > > > session.name - PHPSESSID
    > > > session.referer_check - no value
    > > > session.save_handler - files
    > > > session.save_path - /tmp
    > > > session.serialize_handler - php
    > > > session.use_cookies - On
    > > > session.use_trans_sid - 1
    > > >
    > > > I created a the directory /tmp on my webspace, but it didn't help at
    > all.
    > > > Any help here would be appreciated.
    > > >
    > > > Thanks
    > > > Mark Liam
    > > >
    > > >
    > >
    > >
    >
    >

    Dung Nguyen Guest

  8. #7

    Default Re: Sessions not working

    Thanks for your help. I've added session_start() to the top of every page
    and it works fine. I was leaving it out because only certain users
    (moderators) had information that needed to be stored in sessions. Regular
    users don't have any information that required sessions, but I guess it
    won't really hurt if everyone uses them.

    "Dung Nguyen" <dung@ucdavis.edu> wrote in message
    news:bumlh6$2v$1@woodrow.ucdavis.edu...
    > Mark,
    >
    > Web servers are stateless machines. Each URL request, i.e. each page is
    its
    > own entity. The idea behind session is to provide a mechanism for
    defining
    > states. Having said that, the session_start() function called in
    admin.php
    > is complete once PHP reaches the bottom of the page (admin.php). The
    > session information would have been written out to a temporary file. The
    > next page the user accesses, e.g. user.php knows nothing of your intention
    > to use the previous states unless you tell it too, i.e. via a call to
    > session_start().
    >
    > So at the top of every page you need to call session_start() so that it is
    > able to access the information stored in the session.
    >
    > Hope that helps.
    >
    > -DN
    >
    >
    > "Mark" <npspam@omas.com> wrote in message
    > news:uGAPb.53685$7JB1.45230@news04.bloor.is.net.ca ble.rogers.com...
    > > It's being called only in the admin file, at the top of the page before
    > the
    > > script outputs anything to the screen. The code I'm using is below
    > > (simplified). It starts a session in admin.php, sets
    > $_SESSION['username']
    > > to "BLACK" and then provides a link to index.php. If I follow the link
    > to
    > > index.php, which echos the contents of $_SESSION['username'] to the
    screen
    > > and nothing appears. Index.php does not call session_start again
    because
    > > I'm only using sessions for specific accounts and the code is set up to
    > only
    > > start a session when a user logs in (only moderators are required to log
    > in,
    > > anyone else can read/post without an account).
    > >
    > > <?php
    > >
    > > // CONNECT TO DATABASE
    > >
    > > $sq = mysql_connect("dbname", "dbuser", "dbpass")
    > > or die("Unable to connect to database: " . mysql_error() . "<BR>");
    > >
    > > mysql_select_db("dbname");
    > >
    > > // IF SUBMIT WAS PRESSED, VERIFY IDENTITY
    > >
    > > if ($_POST["submit"]) {
    > >
    > > // QUERY DATABASE FOR MATCHING USER/PASSWORD
    > >
    > > $result = mysql_query("SELECT * FROM users WHERE uname='$adminname' AND
    > > upass='$adminpass'")
    > > or die("Unable to query database: " . mysql_error() . "<BR>");
    > >
    > > if (mysql_num_rows($result) <= 0) {
    > > echo("<BR><CENTER><B>Invalid username/pasword combination. Click <A
    > > HREF=\"admin.php\">here</A> to try again.</B></CENTER><BR><BR><BR>");
    > > }
    > >
    > > // username & password match
    > > // begin session...
    > >
    > > else {
    > >
    > > session_start();
    > >
    > > $_SESSION['username'] = "BLACK";
    > >
    > > echo("Session id: " . session_id());
    > > echo("<A HREF=\"index.php\">Index</A>");
    > >
    > > }
    > >
    > > mysql_free_result($result);
    > > mysql_close($sq);
    > > include("incs/footer.php");
    > > exit();
    > > }
    > >
    > > ?>
    > >
    > > "Dung Nguyen" <dung@ucdavis.edu> wrote in message
    > > news:bumkdj$ric$1@woodrow.ucdavis.edu...
    > > > Mark,
    > > >
    > > > > ... once the user leaves the page where session_start() was
    originally
    > > > called.
    > > >
    > > > When and where are you calling session_start() ?
    > > >
    > > > Just in the Admin.php file?
    > > >
    > > > -dn
    > > >
    > > >
    > > > "Mark" <npspam@omas.com> wrote in message
    > > > news:L8APb.53191$7JB1.9536@news04.bloor.is.net.cab le.rogers.com...
    > > > > After starting a session and assigning data to the session variable
    > (ie.
    > > > > $_SESSION['username']), the variable only contains a value on the
    page
    > > the
    > > > > session was created on.
    > > > >
    > > > > For example, moderators on my site log into their accounts on a page
    > > > called
    > > > > admin.php. Once the username/password have been matched against the
    > > > values
    > > > > in the mysql database, I want to assign the username to
    > > > > $_SESSION['username'] so it's available on all pages.
    > > > >
    > > > > If I print out the contents of $_SESSION['username'] on admin.php
    > right
    > > > > after they've logged in, it will display their username without
    > problem,
    > > > but
    > > > > once the user leaves admin.php, $_SESSION['username'] is blank.
    > > > >
    > > > > It doesn't seem to matter if I attach PHPSESSID=session_id() to the
    > URL
    > > or
    > > > > not. $_SESSION['username'] is always blank once the user leaves the
    > > page
    > > > > where session_start() was originally called.
    > > > >
    > > > > Does anyone have any ideas on why this might be? Here are my hosts
    > > > session
    > > > > settings from phpinfo() in case they're relevant:
    > > > >
    > > > > session.auto_start - Off
    > > > > session.cache_expire - 180
    > > > > session.cache_limiter - nocache
    > > > > session.cookie_domain - no value
    > > > > session.cookie_lifetime - 0
    > > > > session.cookie_path - /
    > > > > session.cookie_secure - Off
    > > > > session.entropy_file - no value
    > > > > session.entropy_length - 0
    > > > > session.gc_maxlifetime - 1440
    > > > > session.gc_probability - 1
    > > > > session.name - PHPSESSID
    > > > > session.referer_check - no value
    > > > > session.save_handler - files
    > > > > session.save_path - /tmp
    > > > > session.serialize_handler - php
    > > > > session.use_cookies - On
    > > > > session.use_trans_sid - 1
    > > > >
    > > > > I created a the directory /tmp on my webspace, but it didn't help at
    > > all.
    > > > > Any help here would be appreciated.
    > > > >
    > > > > Thanks
    > > > > Mark Liam
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Mark Guest

  9. #8

    Default Re: Sessions not working

    In that case, what you can do is check either their username or privilege
    level to determine whether you should start/stop the session for that user.


    "Mark" <npspam@omas.com> wrote in message
    news:znBPb.54429$7JB1.42719@news04.bloor.is.net.ca ble.rogers.com...
    > Thanks for your help. I've added session_start() to the top of every page
    > and it works fine. I was leaving it out because only certain users
    > (moderators) had information that needed to be stored in sessions.
    Regular
    > users don't have any information that required sessions, but I guess it
    > won't really hurt if everyone uses them.
    >
    > "Dung Nguyen" <dung@ucdavis.edu> wrote in message
    > news:bumlh6$2v$1@woodrow.ucdavis.edu...
    > > Mark,
    > >
    > > Web servers are stateless machines. Each URL request, i.e. each page is
    > its
    > > own entity. The idea behind session is to provide a mechanism for
    > defining
    > > states. Having said that, the session_start() function called in
    > admin.php
    > > is complete once PHP reaches the bottom of the page (admin.php). The
    > > session information would have been written out to a temporary file.
    The
    > > next page the user accesses, e.g. user.php knows nothing of your
    intention
    > > to use the previous states unless you tell it too, i.e. via a call to
    > > session_start().
    > >
    > > So at the top of every page you need to call session_start() so that it
    is
    > > able to access the information stored in the session.
    > >
    > > Hope that helps.
    > >
    > > -DN
    > >
    > >
    > > "Mark" <npspam@omas.com> wrote in message
    > > news:uGAPb.53685$7JB1.45230@news04.bloor.is.net.ca ble.rogers.com...
    > > > It's being called only in the admin file, at the top of the page
    before
    > > the
    > > > script outputs anything to the screen. The code I'm using is below
    > > > (simplified). It starts a session in admin.php, sets
    > > $_SESSION['username']
    > > > to "BLACK" and then provides a link to index.php. If I follow the
    link
    > > to
    > > > index.php, which echos the contents of $_SESSION['username'] to the
    > screen
    > > > and nothing appears. Index.php does not call session_start again
    > because
    > > > I'm only using sessions for specific accounts and the code is set up
    to
    > > only
    > > > start a session when a user logs in (only moderators are required to
    log
    > > in,
    > > > anyone else can read/post without an account).
    > > >
    > > > <?php
    > > >
    > > > // CONNECT TO DATABASE
    > > >
    > > > $sq = mysql_connect("dbname", "dbuser", "dbpass")
    > > > or die("Unable to connect to database: " . mysql_error() . "<BR>");
    > > >
    > > > mysql_select_db("dbname");
    > > >
    > > > // IF SUBMIT WAS PRESSED, VERIFY IDENTITY
    > > >
    > > > if ($_POST["submit"]) {
    > > >
    > > > // QUERY DATABASE FOR MATCHING USER/PASSWORD
    > > >
    > > > $result = mysql_query("SELECT * FROM users WHERE uname='$adminname'
    AND
    > > > upass='$adminpass'")
    > > > or die("Unable to query database: " . mysql_error() . "<BR>");
    > > >
    > > > if (mysql_num_rows($result) <= 0) {
    > > > echo("<BR><CENTER><B>Invalid username/pasword combination. Click <A
    > > > HREF=\"admin.php\">here</A> to try again.</B></CENTER><BR><BR><BR>");
    > > > }
    > > >
    > > > // username & password match
    > > > // begin session...
    > > >
    > > > else {
    > > >
    > > > session_start();
    > > >
    > > > $_SESSION['username'] = "BLACK";
    > > >
    > > > echo("Session id: " . session_id());
    > > > echo("<A HREF=\"index.php\">Index</A>");
    > > >
    > > > }
    > > >
    > > > mysql_free_result($result);
    > > > mysql_close($sq);
    > > > include("incs/footer.php");
    > > > exit();
    > > > }
    > > >
    > > > ?>
    > > >
    > > > "Dung Nguyen" <dung@ucdavis.edu> wrote in message
    > > > news:bumkdj$ric$1@woodrow.ucdavis.edu...
    > > > > Mark,
    > > > >
    > > > > > ... once the user leaves the page where session_start() was
    > originally
    > > > > called.
    > > > >
    > > > > When and where are you calling session_start() ?
    > > > >
    > > > > Just in the Admin.php file?
    > > > >
    > > > > -dn
    > > > >
    > > > >
    > > > > "Mark" <npspam@omas.com> wrote in message
    > > > > news:L8APb.53191$7JB1.9536@news04.bloor.is.net.cab le.rogers.com...
    > > > > > After starting a session and assigning data to the session
    variable
    > > (ie.
    > > > > > $_SESSION['username']), the variable only contains a value on the
    > page
    > > > the
    > > > > > session was created on.
    > > > > >
    > > > > > For example, moderators on my site log into their accounts on a
    page
    > > > > called
    > > > > > admin.php. Once the username/password have been matched against
    the
    > > > > values
    > > > > > in the mysql database, I want to assign the username to
    > > > > > $_SESSION['username'] so it's available on all pages.
    > > > > >
    > > > > > If I print out the contents of $_SESSION['username'] on admin.php
    > > right
    > > > > > after they've logged in, it will display their username without
    > > problem,
    > > > > but
    > > > > > once the user leaves admin.php, $_SESSION['username'] is blank.
    > > > > >
    > > > > > It doesn't seem to matter if I attach PHPSESSID=session_id() to
    the
    > > URL
    > > > or
    > > > > > not. $_SESSION['username'] is always blank once the user leaves
    the
    > > > page
    > > > > > where session_start() was originally called.
    > > > > >
    > > > > > Does anyone have any ideas on why this might be? Here are my
    hosts
    > > > > session
    > > > > > settings from phpinfo() in case they're relevant:
    > > > > >
    > > > > > session.auto_start - Off
    > > > > > session.cache_expire - 180
    > > > > > session.cache_limiter - nocache
    > > > > > session.cookie_domain - no value
    > > > > > session.cookie_lifetime - 0
    > > > > > session.cookie_path - /
    > > > > > session.cookie_secure - Off
    > > > > > session.entropy_file - no value
    > > > > > session.entropy_length - 0
    > > > > > session.gc_maxlifetime - 1440
    > > > > > session.gc_probability - 1
    > > > > > session.name - PHPSESSID
    > > > > > session.referer_check - no value
    > > > > > session.save_handler - files
    > > > > > session.save_path - /tmp
    > > > > > session.serialize_handler - php
    > > > > > session.use_cookies - On
    > > > > > session.use_trans_sid - 1
    > > > > >
    > > > > > I created a the directory /tmp on my webspace, but it didn't help
    at
    > > > all.
    > > > > > Any help here would be appreciated.
    > > > > >
    > > > > > Thanks
    > > > > > Mark Liam
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >
    > >
    > >
    >
    >

    Dung Nguyen Guest

Posting Permissions

  • You may not post new threads
  • You may 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