Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Cookies And Redirect - Not Setting Cookie.


I've got the following code :

if (empty($g_view_all_cookie_val)) {
$t_settings_string = "v1#any#any#any#";
setcookie($g_view_all_cookie, $t_settings_string/**
* DG, time()+$g_cookie_time_length
*/);
print_header_redirect($g_view_all_page . "?f=2");
}

I am running this on PHP, IIS5 on windows 2000 server. When I run the
page it goes into a loop, it seems that the $g_view_all_cookie_val var
never gets set. If I run the same pages on II6 on Windows XP it runs




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Setting Cookies, Setting Timestamp Instead...
im setting cookies for my login and instead of storing the values i want it to, its storing a timestamp instead my code is in a few pages, althoug ill summerise my data, and only post the code that creates the cookies: Code:

Setting More Than One Cookie
Has anyone else had trouble setting more than one cookie?  I think I am.  Any solutions, if so?

Problem Setting Cookie Please Help!
I am running the following code to set a cookie but it is not working,

The code is from an online article

I am using Windows 2000 SP5, PHP 4.2.3, MYSQL 4.0.13-nt, apache 2.0.45

<?php
$psEmail = $_POST["psEmail"];
$psPassword = $_POST["psPassword"];
$psRefer = $_Post["psRefer"];

// Check if the information has been filled in
if($psEmail == '' || $psPassword == '')
{
// No login information
header('Location: LoginTest.php?refer='.urlencode($psRefer));
}
else
{
// Authenticate user
$hDB = mysql_connect('localhost', 'root', 'sarah');
mysql_select_db('TestData', $hDB);
$sQuery = "Select iUser, MD5(UNIX_TIMESTAMP() + iUser +
RAND(UNIX_TIMESTAMP())) sGUID From tblUser Where sEmail = '$psEmail'
And sPassword = password('$psPassword')";

$hResult = mysql_query($sQuery, $hDB);
if(mysql_affected_rows($hDB))
{
$aResult = mysql_fetch_row($hResult);
// Update the user record
$sQuery = "
Update tblUser
Set sGUID = '$aResult[1]'
Where iUser = $aResult[0]";
mysql_query($sQuery, $hDB);
// Set the cookie and redirect
setcookie("session_id", $aResult[1], time() + 3600)
}
else
{
// Not authenticated
header('Location: LoginTest.php?refer='.urlencode($psRefer));
}

}
?>

Problems Setting Cookie
I wrote a small script setting a cookie.... but nothing is being set.
What could be the problem?! Did I make something wrong?! One script is
used to ask for the cookie and the other one shows the displayed
variable in a string only! But if I look at Firefox in the cookie cache
if the variables are set... I didn't find anything. what could be the
problem?!

Apache 2.0.54 with PHP 5.1 RC1 on Gentoo Linux 2005.1

1st Script: Abfrage.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<?
ob_start();
?>
<html>
<head><title>Registrierungsformular</title>
<link rel="stylesheet" href="eigenschaft.css" type="text/css">
</head>
<body>
<center>
<?
if (isset($_POST["register"]) && ($_POST["register"] == 'Abschicken!')
&& ($uid = check_auth($_POST["Login"],$_POST["Passwort"])))
{
setcookie('uid',$uid,time() + 14400,'/');
header('Location: http://localhost/~tamer/Anmeldung.php');
exit();
} else {

?>
<h1>Hallo... dies ist ein Test!</h1>
<form method="POST" action="Anmeldung.php">
<table>
<tr>
<td>Login: </td>
<td><input type='text' name="Login"></td>
</tr>
<tr>
<td>Passwort: </td>
<td><input type='password' name="Passwort"></td></tr>
<tr><td><input type="submit" name="register" value="Abschicken!"></td></tr>
</table>
</form>
</center>
<?
}
?>
</body>
</html>

2nd Script: Registrierung.php:

<?
$login = $_REQUEST["Login"];
$Passwort = $_REQUEST["Passwort"];

print "Mein Login ist: $login und das Passwort ist: $Passwort";
?>

Coding For PHP Cookie Setting...
I want to submit a form to it's self and then set a cookie with the sent variables from the form. Then I want to call this cookie to set the variables in the submit form next time it is visited, so they don't have to keep typing it in ever time they visit. ie-
Code:

Setting Cookie From A Class
I keep getting the error stating that you can't write a cookie as there has already been output sent to the browser. The actual error is as follows: Code:

Warning: Cannot add header information - headers already sent by (output started at {path deleted} php code:

Setting A Permanant Cookie
what im trying to do here is set a permanant cookie (which contains a time stamp) on 1 of my pages so i can track the users last visit, i have included a seperate file on this page called timestamp.php my question is how would i go about setting this cookie in the timestamp.php Code:

Setting Two Cookies
I've got a question! i've got a page where a user can login and i want that page to create two cookies, one containing the md5()'ed password, the other one containing the username...

originally, i wanted to have one cookie storing those 2 values by putting an array into it as the cookie value, but php said that only strings were allowed!

now i try to set too cookies at one like this:

setcookie("cookie1",$value1);
setcookie("cookie2",$value2);

but it doesn't work (guess it's because header informations are already sent after setting the first cookie, but it doesn't show any warning similar to that)... only cookie1 is set, but not cookie2!

Setting Cookies
i run my website by typing in localhost and set the cookie and it works. i can also do this by typing in the ip address and the setcookie works again. The problem arrises when i try running the website by typing in the domain name. i set the cookie but it says there is not one there. there is the website so you can see the error message. i dont understand y this should only fail when loading the page using a url masking.

Setting Cookies
Is there a way to set cookies forever of do you just set them for a very long time?

How To Redirect After Setting Session?
I have a login page that is supposed to redirect the user to his private
page after login. But header("Location: $url") does not work after I set
the $_SESSION variable - I get "Warning: Cannot modify header information -
headers already sent by ...

The abbreviated code on the login page looks like this:

<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
[etc, etc]
[login form]
<?
if (credentials are valid)
{
session_start();
$_SESSION['username'] = $uid;
header("Location: $url");
}
?>

One option I've heard about is using ob_start() at the top of the page - but
that seems to screw up my session. I could also use Javascript like this:

<script language="javascript">
window.location.href=("<?php echo $url; ?>");
</script>

but then folks without Javascript won't get redirected.

Problems Setting Cookie Paramters
For some reason, the php function "session_set_cookie_params" doesn't seem to be working for me. When I use code such as

session_set_cookie_params(time()+8600, '/path', 'some.place.com');

the only parameter that gets set is the duration of the cookie. Everything else defaults the the php.ini default parameters. What gives?

Setting Cookie With Session Variable
I am trying to send a random number from my first page to my second page with a session. That works fine, but the reason I am sending this random number from my first page to my second page with a session; is because I have used it to set a cookie and I want my second page to check for the cookie. The cookie sets fine, but when I try to check for my cookie in my second page; it does not work. Code:

Setting A Cookie On Page Load
How can I set a cookie the first time page loads?

[NEWBIE] Setting Cookies!
Hey,

I want to be able to filter the content of a page according to a username. I think the best way to do this is to set a cookie at the login page, taking the username, and then using that cookie as the criteria for my SQL statement in the query....

How do I set the username into a cookie from a form in a previous page? Can anyone show me the code that i would need to write into the form?

Mod_auth_mysql Setting Cookies
is it possible to set a cookie or session with the user data entered in the llogin window? Since it's using the normal .htaccess style of login I cannot really trigger a php set cookie or session command. And even if I would make the index file set session / cookie, I wouldn't know how to get the data entered in the login procedure. any ideas ?

Setting And Deleting Cookies
I'm using PHP 4.4.4 on Fedora Core 5 Linux. Two questions, if I
create a cookie under the "/" path ...

setcookie('LoggedIn', 1, time() + REMEMBER_ME_TIME, "/");

1. How do I check if this cookie is set at the top of a given PHP
page?

2. How do I delete this cookie?

Session Cookie Setting Only For Host Instead Of Domain
I'm trying to set a cookie to apply over all hosts in my domain.

I have a settings file setting
$domain ="quietcare.info";
$cookieDomain = ".".$domain;

Then I use that $cookieDomain as an argument in my set-cookie command.

But it doesn't seem to be working. My browser still shows the
cookie-set request as being just for the host, not for the domain. And
when I go to another server in my domain and look at the full request,
I don't see that cookie value as set.

What am I missing?

Does the domain arg only apply to stored cookies? (I read that in an
ASP document, it seemed horribly stupid, but still...) (My servers run
Linux.)

Setting Cookies For Multiple Directories
I'm having a little trouble getting 'sitewide' cookies to work. Code:

setcookie ("facilityidcookie",$facilityid,time()+14400,"/");

This is supposed to set a cookie from the root level and have the cookie available for all directories below root. For some reason it does not work as intended. The cookie works great for root level docs, but all sub directories do not see the cookie.

PHP Setting Cookies For Multiple Domains
Is it possible to set a cookie for another domain?

Basically what I want to do is set a cookie from domainX for domainY.  On domainY I want it to read to be able to read the cookie.  Currently when I set the domain arg using setcookie to a different domain it doesn't create the cookie.

Setting A Session Variable Via A Hyperlink, Then Redirect
I usually have my nose in photoshop or flash, so PHP is still very new to me.  The project I've been given is to have a spanish version of our cardholder site.  The way I've achieved it so far is..

Create a php file that has all of the english/spanish translations in arrays.  An example would be Code:

Conditional PHP Cookies; If Cookie = 1 Do This...
I've figured out cookies ... now I'm trying to combine them with if conditions.

For cookie 'bandwidth1' I want to echo that it is set to 1 by the cookie to confirm this in the brower through regular html.

My if/else statements don't seem to be working though...heres the code I have now.

<?php
setcookie("bandwidth1","0",time()+2592000,"/");
setcookie("bandwidth2","1",time()+2592000,"/");
setcookie("bandwidth3","2",time()+2592000,"/");
?>

<?php
if (isset($_COOKIE["bandwidth1"])=="1")
echo "Bandwidth is 1!";
else
echo "Bandwidth is unknown";
elsif
echo "Cookie was not set?";
?>

Sending Session Cookie Before Redirect
I have a function in a lot of pages, which redirects to a new page, if
a form has been submitted:

if (!(defined("DEBUG_INSERT") && DEBUG_INSERT) &&
!(defined("DEBUG_UPDATE") && DEBUG_UPDATE) &&
!(defined("DEBUG_SELECT") && DEBUG_SELECT)){
if ($_POST){
$_SESSION["postvalue"] = $_POST;
header("HTTP/1.1 302 Moved Temporarily");
header ("Location: ".BASE_URL.$sess->assemble(),true, 302);
header("Connection: close");
exit();
}else{
if (isset($_SESSION["postvalue"])){
$_POST = $_SESSION["postvalue"];
}
}
}

In conjunction with a login form and a browser that accepts cookies
for the session handling, this leads to everyone having to enter his
login and pasword twice.

i believe this is, because the cookie do not get sent before the
header ("Location:


Cookies Not Working With Header() Redirect
I'm using the cookie to store the user's session ID. After they login, they are redirected to the page (index.php) they are supposed to hit after logging in. Index.php checks to make sure that everything is in order and if there isn't a cookie with the right info it will dump them back to the login page.

The problem comes after the user logs in...like I said, they are redirected after logging in; however, when I do this, index.php does not recognize that there was a cookie set. If I take out the redirect header() from the login page and just supply a link to index.php that the user must click after they login, everything works. From the php manual: Cookies will not become visible until the next loading of a page that the cookie should be visible for...A nice way to debug the existence of cookies is by simply calling print_r($_COOKIE);.

I think that this might be part of the problem, and that somehow the header() isn't being recognized as an actual "page load." Just for the record cause I know someone will proly ask, I have called print_r($_COOKIE);to see if the cookie is set and it is.

Differance Between Session Cookies And Persistent Cookies
Can anybody knows the differance between Session cookies and persistent
cookies.

Only 20 Cookies? - Please Give Me More Cookies!
I am building a "custom links" feature on a web site. Currently, I am storing the url in a cookie and the name of the web site in another cookie. Having 10 custom links would mean 20 cookies. However, in the specifications of cookies (Netscape), there is a maximum limit of 20 on the number of cookies per domain.

My question is: I know of a site at http://www.hammervald.se/search-this/

which got around the problem by using a BIG cookie with all the information separated by a delimiter such as %. Would would be the code to parse this string in the cookie?

Suppose the contents of my cookie is:
CookieName = "URL1%site1.com%NAME1%site#1%URL2%site2.com%NAME2%site#2%URL3%site3.comNAME3%site#3..."

How would I parse this string to get the following variables?

$URL1 = "site1.com"
$NAME1 = "site#1"... etc

Also, what would be a good delimiter to use? Is % very compatible?

Help Setting SSL In IIS, And How To Use It
Help me how to setting SSL in IIS in XP, and how to use it,.. anybody have the reference of using SSL?

Setting Of <? And <?php
I'm now doing web programming using PHP. I need to use <?php instead of <?
for PHP scripts.

How do I configure PHP so that it can recognize <? as well?

Setting ID
I have succesfully selected pictures and text from a database and displayed them in a table. But now I need to be able to click on the picture and then it opens a page with all the details from the databse about it. I know I need to have some code that selects the ID from the databse and then shows the pictures and text.

The problem I am having is getting the picture to have the unique ID.

Setting Up A Cron-Job
I need to setup a cron-job through a PHP Script.

If anybody does know how to do this through php script.

Setting Up Php.ini For Smtp Using Iis
I'm trying to make my web server a mail server and web server in one, kind of. I wan't my server to send out emails when requested by php using the smtp server of Microsoft iis. But one problem, I don't know how to set up IIS or php.ini to work with eachother.

I set up iis so I can recieve email through my server from a domain. But I don't know how to get it so that php uses IIS to send emails out with smtp. Does anyone know how to do this? If not, does anyone know how to make my server a windows smtp mail server that works with php?

Setting Up PHP4
I have set up PWS and PHP4 on my Windows98 computer but I am still unable to see php coding in .php files in IE. Yes I have put them in the right dir. I think the problem was that I was unable to put the file msvcrt.dll in my C:WINDOWSSYSTEM folder. When ever I try to copy that file into C:WINDOWSSYSTEM I get an error message that says "Cannot creat or replace msvcrt: The specified file is being used by Windows." Whats going on here?

Setting Checkboxes
I have a script which iwant to use to check some check boxes based on a query. It does not work partly because some of the code is borrowed and because I'm abit of my depth.
PHP Code:

Setting Up A PHP Debugger...
My current setup is:

Workstation:
PHPEdit and Dreamweaver MX 2004

Server:
Win2k server w/IIS, PHP 4.3.6 and MySQL 4.0.18

My source files are located on my workstation, and when saved, they are
automatically copied to my server. For me, this is fine, however I know it
is not the best practice.

I do like how Dreamweaver manages the sites, both local and remote (and I am
not using the testing server).
Right now, I basically make changes, refresh the LIVE page and see if it
works, if not, undo and try again, etc.

I would like to start using the debugger in PHPEdit, but am confused on the
setup. Does it debug the pages on my local machine, but pull the db stuff
from the server ? Do I have to setup IIS on my XP box to debug or does the
debugging take place on the web server itself ?

My site is a VERY heavily gutted and modified PHPNuke install.

I haven't clue one on how to setup of "true" web development environment.
All these machines are in my house, on my LAN.

Setting Up Cronjob
I want to set up a cronjob to carry out basic maintenence of my site. I have read a tutorial at phpfreaks on cronjobs; however, it seems to only be of use if I have command line access, to the server, which I don't believe I do. My web host uses cPanel, which has a web interface for setting up cronjobs. As a test, I saved the following to 'test.php': PHP Code:

Setting Locale?
I have this thing I wrote called "Simple Contact Form." It's just a
straight-forward contact form. (Rather than repeat myself, check out
http://jimsun.linxnet.com/SCForm.html if you need to know more.)

I just received this email:

In the swedish alphabet we have three characters, å (an a
with a smal circle over it) ä ( an a with two spots ower it)
and ö ( an o with two spots over it). When I use the
emailform those chacters doesn't show as they should. Have
you any idea of what might be the cause of this?

Is this a problem with the locale not getting set?

In Perl, the thing to do is make sure to do a "use locale." But I
really haven't been able to find anything regarding a "standard
recommendation" for PHP.

From what I *have* found, it looks like what I want to do is
something like:

In the application's config file:

// Set this manually if the system default isn't the right thing
$locale = "";

In the code:

@setlocale(LC_ALL, $locale);

Is this right?

Setting Up Database
I am trying to write a script that will setup my main script by writing the config files, headers, footers, & setting up the database. I have it all done except for setting up the databse. I would like to just have a db.sql file that I could generate from phpmyadmin, and some how load that into the database is this posable? and if so how can I do it. the db would have 5 tables and only one of those tables would have data in it PHP Code:

Setting Up My First Database
If I want to set up my first database and start using it in
Dreamweaver what do I need to do?

The book I'm working on has a CD with the database on. It is telling
me to put it in the MySql folder on drive C.

However, when I'm in Dreamweaver I click on Applications at the side,
and the plus button to add a MySql database. It tells me to enter the
following info:

Connection Name: conn_newland
MySQL Server: localhost
Usename:root
Password:leave password blank
Database:newland_tours

If I enter all this info and click to test it comes up with error 1049
unknown database. This makes me wonder whether I have put the
database in the correct folder? When I click on the select button
next to Database within these settings it only lists two databases:
test and mysql. The newland_tours.sql database that I put into the
MySql folder on drive C is not listed.

Am I doing something wrong do you know and should this be in another
folder?

Win XP Pro / DW 7.0.1
Running locally: Apache 2.0.49 / PHP 4.3.7 / MySQL 4.0.20a

Setting _post
is there a way to set _post variables without submitting a form?

something like

<?php
$_POST['var1']=123;
?>
<a href="something.php">link</a>

when user clicks on a link the something.php script can access
$_POST['var1']

Setting Include_path To No Value?
How can i set include_path = no value in my php.ini If i leave it blank:
include_path = and then check the settings with phpinfo() this is what i get
include_path = .:usr/local/lib/php

Variables_Order Setting
According to an O'Reilly PHP book I have, setting variables_order to "ES" is
safer, but that one will need to create global variables, not rely on them
being created.

Fair enough. But why does setting variables_order to ES cause the following
to break, even though it is what O'Reilly recommends? The "id" variable is
unpopulated. I have PHP 4.3.4 on Linux.

$id = clean($_GET['id'],5);
$result = mysql_query("SELECT * FROM my_table where id = $id",$db);
$myrow = mysql_fetch_array($result);

Setting Up PHP With Dreamweaver 8
how to set up a testing server with dreamweaver 8 please? How do I make dreamweaver go directly to the site for eg http://localhost/test/test.php? cause if I want to see my test.php I have to type it up everytime.

Max_input_time Setting In Php.ini
The PHP manual (php.net) does not seem to document the meaning of the
default setting of -1 for max_input_time in php.ini. Can anyone give
me this info or tell me where to get it?

Setting Up PHP To Use Mail ( )
I am trying to run this code and I keep on getting the error message :

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:Program FilesSOFTXAMPPxampphtdocs
egister.php on line 96

Any ideas, guys?

#########SEND A REGISTRATION CONFIRMATION E-MAIL##########

if ($adduser)
{
$recipient = "'".$_POST['email']."'";
$subject = "Registartion Confirmation";
$mailheaders = "From: Express PC Sales <xxx@hotmail.com>
";
$msg = "Thank you for registering at Express PC Sales. Your Account is now active. <br><br> If you DID NOT register on our site, please reply back and your account will be removed from our system.";
mail($recipient, $subject, $msg, $mailheaders);
}?>

Btw, I m doing this from localhost AND the FROM e-mail must be xxx@hotmail.com.

Setting Up Cron Job !!!
I need help creating a PHP script that will ... import - ID, user_login and user_pass - into wp_users from another table called jos_users (located in the same database) where these three fields are called - id, username and password.

I need to set up a cron job to do this because new users are being continuously added to the source table.

I can decipher PHP but I can't write it. So, I need someone to code this for me. Hoping some kind and knowledgeable soul will read this and offer their services.

Linux, i686
SQL: 4.1.22-standard
PHP: 4.4.7
Apache: 1.3.37 (Unix)

Strtotime - Setting From Present
I am having trouble setting the strtotime function to echo 'Y-m-d' on any day from 1 - 24 months past.

I have attempted the following from links that call to different ranges of dates; 6 months, 9 months, 12 months, etc. -- from present time:

My SQL is set up as follows:
WHERE Date between 'pastDATE' and CURDATE()
pastDATE = $HTTP_GET_VARS["getDATE"]

<a href="oldies.php?getDATE=<? echo strtotime ("-6 months ago"); ?>"> 6 MONTHS OLD </a>

How can I echo the strtotime as "Y-m-d"?

Problems After Setting Register_Globals = Off
I have been searching this forum for the last day in hopes that someone else has posted a solution to this problem.

I was developing code for a simple news release database. On the admin side, there are 4 pages. The index.php page connects to the MySQL database, and retreives the list of press releases. From that page, a user can add a new posting, deleting an existing posting, or edit an existing posting.

The code was developed with the Register_Globals=On. However, as I have read, this should be left to Off. So I have done so. However, I ran in to some problems.

I was using $id in my code. So, I had to switch it to $_GET['id'] on my index.php page. The postings now display again. The problem I am having is adding new posts and editing existing posts. The delete function still works fine.

Under an existing post on the index.php, and user can click an edit link, or a delete link.

Setting New Object To Null?
How do you set an object to null?

$mail = new PHPMailer();
$mail = ?

Question About Setting Options
I've been trying to get this to work for a while now, but I can't figure it out. Tryed out different suggestions, but can't get it to work the way I would like. Anyhow, I have a list of results I set in a table and at the top I have an option for entering min and max price and/or the option for sorting the table my name, price, or brand. Works great if I enter in a min and max value, but it returns an error if I don't enter in any values or enter in a non numerical value. Well, what I would rather have it do is not return an error and take me to the page using the options it does recognize and ignore the options it doesn't recognize or if it is empty. Here is my code:

if (!isset ($_GET['min'])) {
$min = $default_min;
} else {
$min = $_GET['min'];
}
$default_max = &#55613;&#57176;'
if (!isset ($_GET['max'])) {
$max = $default_max;
} else {
$max = $_GET['max'];
}
$default_sort = 'name'
if (!isset ($_GET['sort']) ) {
$sort = $default_sort;
} else {
$sort = $_GET['sort'];
}
echo "
<form method=get action=/$word/filter>
<table cellspacing=0 border=0 cellpadding=0 width=100%>
<tr>
<td align=left bgcolor=EEEEEE>
<input type=hidden name=category value="$fetch[category]">
<table border=0 cellspacing=0 cellpadding=2 width=485>
<tr>
<td><font color=#666666>Min Price</font> $
<input class=filter type=text size="5" name="min" value=""></td>
<td><font color=#666666>Max Price</font> $
<input class=filter type=text size="5" name="max" value=""></td>
<td align=left>and/or Sort by</td>
<td align=left><select name=sort class=select size=1>
<option value=name>Name</option>
<option value=our_price>Price</option>
<option value=brand>Brand</option>
</select> </td>
<td colspan=2 align=left><input type=submit value=Apply name=update style="color:#333333; background-color:#E0E0D0; font-size:11px;"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>

My query is like so:

$result = mysql_query("select * from evitamins_products WHERE category='$category' and our_price BETWEEN $min and $max ORDER by $sort ASC") or die (mysql_error());


Copyright © 2005-08 www.BigResource.com, All rights reserved