SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Australia
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP cookie implementation

    What is the best way to implement detailed cookies with users login name password and preferences?

    I have used this code in the past

    Session_register( "username" );
    Session_register( "password" );

    but for some reason it is now generating this error.

    Warning: Cannot send session cookie - headers already sent by (output started at releventpage.php:4) in releventpage.php on line 338

    Is there a better way to do this or a way to solve this.

    Thanks,
    WebmasterMattD

  2. #2
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're getting those errors because you are either echo'ing some code out before you are doing the session_start(), or you have some white space before the <?php in your script(s).
    php.net
    Note: If you are using cookie-based sessions, you must call session_start() before anything is output to the browser.
    http://www.php.net/manual/en/ref.session.php
    Oh no! the coots are eating my nodes!

  3. #3
    Wibblesticks Gryff's Avatar
    Join Date
    Oct 2001
    Location
    Asgard
    Posts
    442
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?
    session_start
    ();
    $up = array("username""password");
    session_register("up");
    header("Location: [url]http://www.blahblah.com/verify[/url]");
    this will put username and password into an array called $up
    you can access username by $up[0] and password by
    $up[1]
    the header command then takes you to
    www.blahblah.com/verify.php
    where you can then use session_start();
    and start messing with your variables

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2000
    Location
    Australia
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks heaps for your input, I have fixed the problem.

    Later,

    WebmasterMattD
    WebmasterMattD
    WebmasterMattD.NET


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
  •