PHP super globals

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MaxPain

    PHP super globals

    I am an amateur in PHP coding .... recently I have successfully written
    a database driven site using PHP on Linux .... I am working on a new
    project, which too involves database access (I am using MySQL for this)
    and am facing a peculiar problem ..... I was searching for a solution
    when I came across this group.

    Actually I am working on Windows XP this time and it seems that I am
    not able to access $_SESSION variables .... actually I am writing a
    login script, which on successful submission of a form accesses the
    database and gets the userid which I am storing in $_SESSION['uid']....
    on every subsequent pages I check the validity of his login using this
    $_SESSION['uid'] and comparing cookies and other information stored in
    the database .... I will give you the structure of my programming ...

    there are 4 files a) login.php b) functions.php c)home.php d)
    logout.php
    functions.php is included in all the 3 files ..... it has
    session_start() at its very beginning.

    1. In login.php I am getting the username and password and comparing
    them wih db info ... if successful I am storing userid in
    $_SESSION['uid'] and setting cookies and updating db
    2. I am redirecting to home.php
    3. Here I use a function check() which has the userid as its argument
    4. the userid I need to get from $_SESSION['uid'] ... but this fails
    5. if check fails I call logout.php

    I am usin PHP5.0.5 with Apache2.0.
    Can any of you help me on this???? ...... maybe on windows I need to
    change something in the php.ini file in order to use the $_SESSION
    array.

    If you cannot figure this out then maybe you can suggest some other way
    in which I can access the userid in home.php.
    I really hope you can help me on this .... otherwise my projetct is
    stuck for an indefinite period of time.

  • Ewoud Dronkert

    #2
    Re: PHP super globals

    MaxPain wrote:[color=blue]
    > functions.php is included in all the 3 files ..... it has
    > session_start() at its very beginning.[/color]

    Make sure that every time there is NO output whatsoever to the browser
    before starting the session and manipulating session or cookie variables.
    Output includes any characters (also spaces, newlines) before the first
    "<?php" of the file.

    --
    E. Dronkert

    Comment

    • MaxPain

      #3
      Re: PHP super globals

      I did make sure of that but it is still not working ..... any other way
      you can suggest??

      Comment

      Working...