Re: GET form method and accessing its value into a cookie

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Cookies will not become visible until the next loading of a page.  Assign
the data to a variable at the same time it is assigned to a cookie and call
the variable to make the data visible on the first page.

Cookies must be deleted with the same parameters as they were set with.
Check you new data against the contents of the cookie, if they are
different, delete the cookie and assign the new cookie (also remember to
assign to the "first page variable").

Read this:

http://us2.php.net/manual/en/function.setcookie.php


Mark Cain


----- Original Message -----
From: "Steve Turnbull" <sturnbull@xxxxxxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Thursday, July 21, 2005 5:38 AM
Subject:  GET form method and accessing its value into a cookie


> Hi
>
> I have a page which generates 'edit' links (used to edit user details).
The
> code snippet on the 'list_user.php' page is;
>
> ---
> $print_rows .= "<tr class=\"stdtablecells\"> \n".
> " <td>{$details['name']}</td> \n".
> " <td>{$details['mail']}</td> \n".
> " <td>{$details['quota']}</td> \n".
> " <td><a
> href=\"edit_user.php?user={$user_list[$i]['uid'][0]}\">edit</a></td> \n".
> "</tr> \n";
> ---
>
> The line in question really is this one;
>
> <a href=\"edit_user.php?user={$user_list[$i]['uid'][0]}\">edit</a></td>
\n".
>
> As you can see this creates a link to the 'edit_user.php' page with a GET
> parameter generated by a php array.
>
> The 'edit_user.php' page contains this script (before any headers are
> generated) which is designed to put the GET value into a cookie;
>
> ---
> if (! isset($_COOKIE['yhgfluseruid'])) {
> $useruid = $_REQUEST['user'];
> setcookie('yhgfluseruid', $useruid);
> }
> ---
>
> What happens when actually viewing the pages in a browser, is that the url
> is generated (seemingly) correctly, for example;
>
http://localhost/emailadmin/src/edit_user.php?user=paul.bradley@xxxxxxxxxxx
>
> The only problem is the $user variable doesn't seem to read the cookie, or
> the cookie doesn't get generated before the rest of the page is generated
> and the users details are blank. BUT if I refresh the page, everything is
> fine. Also, if I go back to the 'list_user.php' page, and try editing a
> different user, although the URL suggests that it's passing the correct
> parameters, I end up seeing the details of the previous user?
>
> Help please (sorry for the long description - I am just trying to be
> accurate)
>
> Regards
> Steve
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux