Results 1 to 21 of 21

Thread: couldnt retrieve cookie value!!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Question couldnt retrieve cookie value!!

    i have set the userID and password to cookie but when i want retrieve it, i cant get the value...why?

    set cookie:
    VB Code:
    1. Session_start();
    2.  
    3. if (numRow > 0) then
    4.       $_SESSION["usr"] = username;
    5.       $_SESSION["pwd"] = pss;
    6.       'do stuff
    7. } else{
    8.       'do stuff
    9. }

    Retrieve cookie:
    VB Code:
    1. Session_start()
    2.  
    3.        $usr = $_SESSION["usr"];
    4.        $pss = $_SESSION["pwd"];

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: couldnt retrieve cookie value!!

    If you check in your cookies folder do you see the cookies you've set? Depending on your browser and/or ineternet security software settings they may be blocking your cookies from being set as well. HTH

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    still cannot retrieve value

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: couldnt retrieve cookie value!!

    Have the cookies been created if you look in your cookies folder?

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    i hv create a folder for store the cookie(all setting is done for path to save the cookies) ,but it still couldnt save the cookie in the folder

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    this is the error message after i login and set the session
    VB Code:
    1. Warning: session_start(): open(/tmp\sess_2e63865d1c9def9f28da56b3273f3476, O_RDWR) failed: No such file or directory (2) in C:\Myserver\www\adminLogin.php on line 16
    2.  
    3. Warning: session_start(): Cannot send session cookie - headers already sent by (output started at C:\Myserver\www\adminLogin.php:16) in C:\Myserver\www\adminLogin.php on line 16
    4.  
    5. Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\Myserver\www\adminLogin.php:16) in C:\Myserver\www\adminLogin.php on line 16
    6. Wrong !!b8bc49ce17ceaa21862e920068738827
    7. Warning: Unknown(): open(/tmp\sess_2e63865d1c9def9f28da56b3273f3476, O_RDWR) failed: No such file or directory (2) in Unknown on line 0
    8.  
    9. Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

  7. #7
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: couldnt retrieve cookie value!!

    Post your code as it will help us to determine what the problem is.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    VB Code:
    1. <?php
    2.  
    3.     $adminUserID = $_POST['txtAdminUserID'];
    4.     $adminPass = md5($_POST['txtAdminPass']);
    5.  
    6.     $host ="localhost";
    7.     $dbname = "Broadcast";
    8.     $dbpass = "";
    9.  
    10.     $connection = mysql_connect("$host", "$dbname");
    11.     $db = mysql_select_db("$dbname", $connection);
    12.  
    13.     $results =  mysql_query("select * from tblAdmin where UserID ='$adminUserID' and Password ='$adminPass'", $connection);
    14.     echo mysql_error();
    15.  
    16.     session_start();
    17.  
    18.     if (mysql_NumRows($results)>0){
    19.  
    20.     $_SESSION["adminUID"] = $adminUserID;
    21.     $_SESSION["adminPass"] = $adminPass;
    22.    
    23. ?>
    24.  
    25.     <script language = "JavaScript">
    26.     document.location.href = "HomePage.htm";
    27.     </script>
    28.  
    29. <?php
    30.  
    31.     } else {
    32.         echo "Wrong !!";
    33.        
    34.     }
    35. ?>

  9. #9
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: couldnt retrieve cookie value!!

    You need to find the session.save_path setting in php.ini and set it to a valid directory otherwise PHP cannot save the session data.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    ya...i have change the path to c:\webCookies and created a folder named "webCookies".......and display the post #6 error

  11. #11
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: couldnt retrieve cookie value!!

    The error in post number 6 says that the save path is "\tmp" are you sure that the script is using that php.ini file?

    Call phpinfo(); to check that it can find php.ini too.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    hmmmm.....same problem!! i alr check the session_savepath is set to c:\webCookies

  13. #13
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: couldnt retrieve cookie value!!

    phpinfo() will tell you which php.ini file is being used, if any.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    type like this??

    VB Code:
    1. echo phpinfo();

  15. #15
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: couldnt retrieve cookie value!!

    No just:
    Code:
    phpinfo();
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    it locate in C:\WINDOWS\php.ini .........what i need to do? change the save.path to this or .........??

  17. #17
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: couldnt retrieve cookie value!!

    Well where is the php.ini you are editing? If it you have not already copy it into C:\windows
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2005
    Posts
    840

    Re: couldnt retrieve cookie value!!

    i edit the php.ini in php inside php folder..........what not really understand what u mean?

  19. #19
    Fanatic Member TDQWERTY's Avatar
    Join Date
    Oct 2003
    Location
    Oporto & Leiria, Portugal / Luanda, Angola
    Posts
    972

    Re: couldnt retrieve cookie value!!

    First thing, that's not cookies, that are sessions.

    <?php
    session_start();
    session_register("yourVar");
    $_SESSION["yourVar"] = $_POST["txtAdminUserID"];

    when you use $_POST['txtAdminUserID'] if the value of txtAdminUserID has spaces it will just read the first part untill the space and the rest of the value will be ignored.

    Second: cookies:

    #########-----> Set cookie

    http/1.0 200
    Content-Length: 1276
    Content-Type: TEXT/HTML
    Date: True, 06 Nov 2001 04:12:49 GMT
    Expires: True, 06 Nov 2001 04:12:59 GMT
    Server: simwebs/3.1.6
    Set-Cokie: animal=egg-laying-mammal

    It's donne like:
    <?php
    setcookie("vegetal", "rice", time() + 3600, "/", "localhost", 0);

    if (isset($_COOKIE["vegetal"])) {print $_COOKIE["vegetal"];}
    ?>

    3rd:
    Be sure that exist:
    C:\Myserver\www\tmp
    or C:\tmp

    4th:

    $results = mysql_query("select * from tblAdmin where UserID ='$adminUserID' and Password ='$adminPass'", $connection);
    That's wrong!
    String are compared using LIKE

    $results = mysql_query("SELECT * FROM `tblAdmin` WHERE UserID LIKE \"$adminUserID\" and Password LIKE \"$adminPass\"", $connection);
    Last edited by TDQWERTY; Oct 16th, 2005 at 09:37 AM.
    ::Winamp 5.xx id3v2 & modern skin support::
    ::NetCF DataGrid Programatically Scroll Example::
    Don't forget to rate posts from those who helped you solving your problem, clicking on and rating it.

  20. #20
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: couldnt retrieve cookie value!!

    Quote Originally Posted by kenny_oh
    i edit the php.ini in php inside php folder..........what not really understand what u mean?
    copy C:\php\php.ini to C:\windows\php.ini then your problem will be solved
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  21. #21
    Member
    Join Date
    Sep 2005
    Posts
    54

    Re: couldnt retrieve cookie value!!

    Is 'session_register("yourVar");' necessary? I've just posted a thread with a similar problem, except the $_SESSION variables are set but can only be retrieved from one page.

    Also Kenny_Oh, it might be wise to validate the data the user puts in the form, bearing in mind your code is open to SQL injection attacks.

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