www.webdeveloper.com
Results 1 to 5 of 5

Thread: Can't keep session continuous between all pages using php

  1. #1
    Join Date
    Jun 2014
    Posts
    3

    Can't keep session continuous between all pages using php

    I have created a session in php where users log in and their data is transferred in all the pages.it looks like this
    PHP Code:
    <?php ob_start();
    session_start();
    error_reporting(0);
    $_SESSION['url'] = $_SERVER['REQUEST_URI'];
    include 
    'cw-config.php';
    if(
    $_SESSION[userid]!='')
    {
    $details=mysql_fetch_array(mysql_query("select * from register where guid='$_SESSION[userid]'"));
    }
    ?>
    It works on all pages except on this one even though i wrote the code in same manner as above one.it looks like this
    PHP Code:
    <?php ob_start();
    session_start();
    error_reporting(0);
    include 
    'cw-config.php';
    extract($_POST);
    extract($_GET);
    $_SESSION['url'] = $_SERVER['REQUEST_URI'];

    if(
    $_SESSION[userid]!=''){ 
    $details=mysql_fetch_array(mysql_query("select * from register where guid='".$_SESSION["userid"]."'"));
    }
    $shopdata=mysql_fetch_array(mysql_query("select * from shop where guid='$shopid'"));
    ?>
    Kindly visit:http://rewardsinn.com the problem is with categories/stores when selected from dropdown menu the session isn't getting transferred I am new to this coding and had redo everything as we were cheated by a designer.it was working fine till yesterday.Kindly help me in this.Once sign in and check to know the problem.

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    663
    how about the missing quotes on userid in your first reference above? if you have some other constant/var named 'userid' then this session ref will not work as expected.

    (all literal array indices SHOULD be in quotes).

  3. #3
    Join Date
    Jun 2014
    Posts
    3
    I tried what u said and changed but the problem remains the same.session isn't getting recorded.visit rewardsinn.com,
    ID:ram
    pwd:123
    after logging in check any category/shop u wil find the problem

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,252
    One possible gotcha is if you sometimes link to a page or form action with a www sub-domain and sometimes don't. You can avoid this issue if you set the session.cookie_domain configuration parameter to be ".yourdomain.com" (note the leading dot). (This could also be done via session_set_cookie_params() in a config file that always gets called before you do your session_start().)
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jun 2014
    Posts
    3
    Thanks...i have removed the www part its working now

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles