Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 2 of 2
  1. #1
    Banned
    Join Date
    Aug 2003
    Posts
    12
    Member #
    2580
    Hi Guys,

    I was hoping that someone here may be able to answer my php question.

    I am using php to create and store cookies for access on a download page. I was wondering if anyone knew the code I would need to say that if the cookie has not been set at the time of the page being viewed, use a set of default values.

    The default values would be

    $username = A000002;
    $password = HM071603;
    $offercode = 03080110700;

    now I'm not a php programmer so I don't know if the syntax for that bit is correct but that at least tells you the variables necessary and the values for those variables. Could someone please help me out with this?

    I was also wondering if the value of a cookie could be defined using a search string query like this:

    http://www.whateverdomain.com/cookie...de=03040710700

    Would that allow you to define the cookie using the values in the url?
    If so, could someone post the proper code for that? I really appreciate it! Hopefully this will help answer questions for others as well.
    Thanks guys!

    Greg J
    design@new-point-0.com

  2.  

  3. #2
    Junior Member IndigoPixel's Avatar
    Join Date
    Jul 2003
    Location
    Brazil
    Posts
    6
    Member #
    2074
    Just check to see if those values are set in the $_COOKIE or $_GET superglobal arrays, then set them if they're not:
    PHP Code:
    $merged array_merge($_GET$_COOKIE);
    if (!
    $merged['username'] || !$merged['password'] || !$merged['offercode']) {
        
    $username 'A000002';
        
    $password 'HM071603';
        
    $offercode '03080110700';

    }
    else {
       
    extract($merged);

    Note that this code is quite insecure, and it would be worth your while to get someone to write the validation part for you ... I can do it, for you, email or PM me if you want me to.

    URL string values are part of the $_GET values ... but you could easily squeeze them out using extract(), and pop them into a cookie, but I'm unsure why you'd want to do that when a cookie is invisible to most users. Even better, use a session, then even if they don't have cookies enabled, you can make it look like they do.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:05 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com