Results 1 to 4 of 4

Thread: PHP + Cookies...

  1. #1
    Cheeko
    Guest

    PHP + Cookies...

    Ive only been doing PHP fer about a week, learnt a bit from various sources, one thing i havent learnt about tho is cookies...

    What I want to do is use two scripts...

    login.php
    home.php

    login script needs to set a cookie and home script needs to check for a cookie, if its there it produces home page with a small message sayong hello to that person if not, it goes to login script...

    Now, I havent a clue how to go about this, so can anyone provide two or three code snippets on setting a cookie, checking for the same cookie and using the cookie to get info from that persons profile?

    I have latest php version on the server, altho we have no mySQL, at the mo, it can be arranged. I'd prefer if I could use the cookie to pick things from a file like:

    000001.cgi

    Name
    Pass
    Hobbies

    Almost exactly like ubb software if you know of it...

    So say we set a cookie, it contains a member number.
    I can then use that number to access a file and grab lines of info i may wish to use...

    So say I have a file named 000001.cgi and it has the info:

    Cheeko
    Cheeko_Pass
    Food

    How would I set a cookie that remembers this persons member number (000001) and then how would I check if that cookie is set (home.php) and then how would I use that cookie to open file 00001.cgi and grab the info on line 3 about hobbies?

    Or if not, where can I learn this?

    Any help offered MUCH:Y appereciated!!

  2. #2
    scoutt
    Guest
    you need to use the setcookie() function. if you go to php.net and read the PHP manual, which by the way is very informative, and read the setcookie() you will find out how to use it.

    it looks pretty simple, but I have not used it.

    good luck, and hope this helps

  3. #3
    Cheeko
    Guest
    Cheers mate, I'll have a looksee!!

  4. #4
    Cheeko
    Guest
    Ok, I've got the cookie set, and I got it to check for it...

    Now then, How do I open a file and assign line one to $var1, line two to $var2 etc...?

    I look for fopen and fileread but no help...?

    Any idea's?

    Thanks LOADS for the setcookie thing to mate

Posting Permissions

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



Click Here to Expand Forum to Full Width