PHP - Any Way To Check If The Cookies Are Enabled By The Browser?
Hello,
is there any way to check if the cookies are enabled by the user's browser rather than storing a cookie and hoping the user is gonna refresh the page so we can test if something is set in the $_COOKIE variable?? I've tried on my localhost, it seems that there are two default cookies (when cookies are enabled) __utma and __utmz, and when the cookies are disabled, the $_COOKIE variable is empty, is that by default in PHP?? Can I rely on that? Enable cookies and test the result of Code: [Select] <?php print_r(var_dump($_COOKIE)); ?> Disable cookies and test the same page, do you get the same results as me? Thanks Similar TutorialsIs there a way for my PHP to check if a user has disabled cookies in their browser, thus breaking my $_SESSION? Since I don't know Javascript, that isn't an option.
I want to give the visitors to my site the option of setting certain preferences and remembering what was chosen from one visit to the next. They might have the choice of setting the backgrond colour of the web page or the font or whatever.
I've already written and tested code to write standard cookies that preserve their choices. However, I'm wondering if that's the best way or if there is a better approach. I don't want visitors to have to re-choose their preferences every time they arrive at the site, which would appear to be the result of using a session cookie stored on the server.
If standard cookies ARE the best solution for my situation, how can I test if the visitor has cookies enabled on their browser? I know that some people definitely don't enable cookies and I'm quite prepared to advise them that they won't be able to save preferences until they enable cookies. However, I first need to know how I can tell definitively if cookies are enabled.
Most of the simple code examples I've found by googling simply try to write a cookie and then try to read it; if both succeed, they think the they've established whether cookies are enabled. The more sophisticated examples, particularly those at stackoverflow, come closer but all of them seem to be critiqued by someone to the effect that they won't work in this or that particular situation.
Given how long cookies and PHP have been in existence, I have to believe that SOMEONE has figured out a definitive way of testing whether cookies are enabled that works in all reasonable circumstances. Can anyone share that technique with me?
I need to use an if statement in conjunction with the browser name/type "Mozilla Firefox" vs "Google Chrome" to display certain scripts of CSS to a page. I am not sure how to do this. Any help would help, Brian Hello All,
I have mod_rewrited working properly but when I enabled SSL it stopped working. Please help me its really frusterating now
RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L] RewriteRule ^shorter/(.*)$ shorter.php?longurl=$1 [L] RewriteRule ^([0-9a-zA-Z]{1,6})$ redirect.php?url=$1 [L] RewriteRule (.*)playlist.xml$ playlist.php [L] # Playlist RewriteRule ^(.*)/$ /index.php?page=$1 [L] RewriteRule ^(.*)/(.*)/$ /index.php?page=$1&id=$2 [L] RewriteRule ^(.*)/(.*)/(.*)/$ /index.php?page=$1&id=$2&no=$3 [L] RewriteRule ^(.*)/(.*)/(.*)/(.*)/$ /index.php?page=$1&id=$2&no=$3&trkid=$4 [L] RewriteRule ^(.*)/(.*)/(.*)/$ /index.php?page=my_profile&code=$2&state=$3 [L]In this site redirects properly to https but it do not work with permalinks http://www.domain.com/music/ << was working fine https://www.domain.com/music/ << Now stopped I Tried RewriteRule (.*)playlist.xml$ https://%{SERVER_NAME}/playlist.php [L] # Playlist #AND Optionally RewriteRule (.*)playlist.xml$ https://www.domain.com/playlist.php [L] # PlaylistBut no success Please help Hi guys, I've been working on a script for a while now, and I'm sure it doesn't look great and all, and it's probably really messed up.. But right now I've finally got it working! There's only 1 thing I'd really like to add.. Searching through & listing of remote directories! The directories I'm trying to list have directory listings enabled, and I think it *should* be possible. I just have no clue how. Here's my current code in a beautiful mix of HTML and PHP: <? $border_size = "0"; function returner($what) { $what=explode("/",$what); $tps=count($what); $what=$what[$tps-1]; return $what; } $page_url= ""; $home_url=returner(__FILE__); if(isset($_GET['q'])) { $qtext=$_GET['q']; } else { $qtext=""; } function getdirsize($directory, $format=FALSE) { $size = 0; if(substr($directory,-1) == '/') { $directory = substr($directory,0,-1); } if(!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) { return -1; } if($handle = opendir($directory)) { while(($file = readdir($handle)) !== false) { $path = $directory.'/'.$file; if($file != '.' && $file != '..') { if(is_file($path)) { $size += filesize($path); } elseif(is_dir($path)) { $handlesize = getdirsize($path); if($handlesize >= 0) { $size += $handlesize; } else { return -1; } } } } closedir($handle); } if($format == TRUE) { if($size / 1048576 > 1) { return round($size / 1048576, 1).' MB'; } elseif($size / 1024 > 1) { return round($size / 1024, 1).' KB'; } else { return round($size, 1).' bytes'; } } else { return $size; } } if(isset($_GET['type'])){ $type=$_GET['type']; } else { $type="new"; } $textures=0; $models=0; $avatars=0; $seqs=0; $sounds=0; foreach (glob("textures/*.jpg") as $texture){ $textures++; } foreach (glob("models/*.zip") as $model){ $models++; } foreach (glob("avatars/*.zip") as $avatar){ $avatars++; } foreach (glob("seqs/*.zip") as $seq){ $seqs++; } foreach (glob("sounds/*.zip") as $sound){ $sounds++; } ?> <!DOCTYPE html> <html> <head> <title>ObjectPath Search</title> <style type="text/css"> #wrapper { width: 850px; margin: 30px auto 30px auto; padding: 10px; } body { color:#C6C6C6; background:#1E1E1E; /* margin:0; padding:0; */ overflow-x:hidden; } #tabs { font: 85% "Trebuchet MS", sans-serif; } .left { float: left; } .right { float: right; } a:link, a:visited, a:active { color: #3DB015; text-decoration: none; } a:hover { color: #00E0FF; } h2 { color: #3DB015; padding-bottom: 0.2em; font-size: 110%; } ul#icon {margin: 0; padding: 0;} ul#icon li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;} ul#icon span.ui-icon {float: left; margin: 0 1px;} </style> <link type="text/css" href="http://objects.jk-hosting.com/search/css/black-tie/jquery-ui-1.8.2.custom.css" rel="stylesheet" /> <script type="text/javascript" src="http://objects.jk-hosting.com/search/js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="http://objects.jk-hosting.com/search/js/jquery-ui-1.8.2.custom.min.js"></script> <script type="text/javascript"> function formHandler(form){ var URL = document.form.site.options[document.form.site.selectedIndex].value; window.location.href = URL; }; $(function(){ // Tabs $('#tabs').tabs(); }); </script> </head> <body> <div id="wrapper"> <div id="tabs"> <!-- Tabs start --> <ul> <li><a href="#tab-search">Search</a></li> <li><a href="#tab-list">List Objects</a></li> <li><a href="#tab-info">OP info</a></li> </ul> <div id="tab-search"><!-- Searchtab start --> Please enter a string to search for, and choose a folder to search in. <br /><br /> <form name="Search"> <input type='hidden' value='search' name='type'> <input value='<? print $qtext; ?>' type='text' name='q'> <select name='map'> <option selected='selected' value='models'>Models</option> <option value='avatars'>Avatars</option> <option value='textures'>Textures</option> <option value='seqs'>Seqs</option> <option value='sounds'>Sounds</option></select> <input type='submit' value='Search'> </form> </div> <!-- Searchtab end --> <div id="tab-list"><!-- Listtab start --> Please pick a folder to browse. <br /><br /> <form name="form"> <select name="site" onChange="javascript:formHandler()"> <option value="#">Look in folder...</option> <option value="<? print $page_url; ?>?type=list&map=models">Models</option> <option value="<? print $page_url; ?>?type=list&map=avatars">Avatars</option> <option value="<? print $page_url; ?>?type=list&map=textures">Textures</option> <option value="<? print $page_url; ?>?type=list&map=seqs">Seqs</option> <option value="<? print $page_url; ?>?type=list&map=sounds">Sounds</option> </select> </form> </div> <!-- Listtab end --> <div id="tab-info"><!-- Info tab start --> The OP currently contains: <br /><br /> <table> <tr><td><b><? echo $models; ?></b></td> <td>Models</td></tr> <tr><td><b><? echo $avatars; ?></b></td> <td>Avatars</td></tr> <tr><td><b><? echo $textures; ?></b></td> <td>Textures</td></tr> <tr><td><b><? echo $seqs; ?></b></td> <td>Seqs</td></tr> <tr><td><b><? echo $sounds; ?></b></td> <td>Sounds</td></tr> </table> </div> <!-- Info tab end --> </div> <!-- Tabs end --> </div> <!-- Start PHP generated content --> <? if($type=="search" || $type=="list") { $M=$_GET['map']; if($type=="search") { $Q=$_GET['q']; $empty="Nothing found with <b>\"" . $Q . "\"</b> in it's name.<br />\nPlease make a more general search query, or try a different folder.\n\n"; } else { $Q=""; $empty='This folder is empty'; } if($M=="textures") { $ext="jpg"; } else { $ext="zip"; } $i=0; print "<hr>\n"; $endfile=array(); $endsize=array(); $endsize2=array(); foreach (glob($M."/*".$Q."*.".$ext) as $filename) { $filename = explode(".", $filename); $filename=$filename[0]; $filename = explode("/", $filename); $filename=$filename[1]; $i++; $endfile[$i]=$filename; if($ext=="jpg") { $endfile[$i]="<a name='".$endfile[$i]."' href='".$pageurl."?type=view&name=".$endfile[$i]."&folder=".$M."&from=".$type."&addon=".$Q."'>".$endfile[$i]."</a>"; } $endsize[$i]=$size; $endsize2[$i]=$size2; } if($i != 1) { print "<b>".$i."</b> items were found.\n<hr>\n"; } else { print "<b>".$i."</b> item was found.\n<hr>\n"; } echo("<table width='100%' border='" . $border_size . "' cellspacing='0' cellpadding='0' >\n"); if($i!=0) { for ($t = 1; $t < $i; $t++) { $thumbfile = $M."/".$endfile[$t].'.jpg'; if(file_exists($thumbfile)) { $thumbnail = "<a name='".$endfile[$t]."' href='".$page_url."?type=view&name=".$endfile[$t]."&folder=".$M."&from=".$type."&addon=".$Q."'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></a>"; } else { $thumbnail = ""; } if($t=="1") { echo("<tr><td width='10%'>Number</td><td width='3%'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></td><td width='60%'>Name</td></tr>\n"); } echo("<tr><td>" . $t . "</td><td>".$thumbnail."</td><td>" . $endfile[$t] . "</td></tr>\n"); flush(); } $thumbfile = $M."/".$endfile[$t].'.jpg'; if(file_exists($thumbfile)) { $thumbnail = "<a name='".$endfile[$t]."' href='".$page_url."?type=view&name=".$endfile[$t]."&folder=".$M."&from=".$type."&addon=".$Q."'><ul id='icon'><li class='ui-state-default ui-corner-all' title='".$endfile[$t]."'><span class='ui-icon ui-icon-image'></span></li></ul></a>"; } else { $thumbnail = ""; } echo("<tr><td>" . $t . "</td><td>".$thumbnail."</td><td>" . $endfile[$t] . "</td></tr>\n"); } print "</table>\n"; if($i=="0") { print $empty; } } elseif($type=="view") { $filename=$_GET['name']; $folder=$_GET['folder']; if($_GET['from']=="list"){ $addon="?type=list&map=".$folder."#".$filename; } if($_GET['from']=="search"){ $addon="?type=search&q=".$filename."&map=".$folder."#".$filename; } print"<center><a href='".$home_url."'>Home</a></center>"; print "<hr>\n<center><img src='".$folder."/".$filename.".jpg'></img></center>\n<hr>\n<br />\n<a href='".$page_url."".$addon."'>Previous Page</a>\n"; } $htmlshow=""; if($_GET['type']=="returnOPfile") { if(isset($_GET['split'])) { $splitter=$_GET['split']; } else { $splitter=" | "; } if(isset($_GET['html'])) { $htmlshow="<br />"; } foreach (glob("textures/*.jpg") as $texture){ if(isset($_GET['size'])) { $size=$splitter.filesize($texture); } $texture = explode("/", $texture); $texture=$texture[1]; print "textures".$splitter.$texture.$size."\n".$htmlshow; } foreach (glob("models/*.zip") as $model){ if(isset($_GET['size'])) { $size=$splitter.filesize($model); } $model = explode("/", $model); $model=$model[1]; print "models".$splitter.$model.$size."\n".$htmlshow; } foreach (glob("avatars/*.zip") as $avatar){ if(isset($_GET['size'])) { $size=$splitter.filesize($avatar); } $avatar = explode("/", $avatar); $avatar=$avatar[1]; print "avatars".$splitter.$avatar.$size."\n".$htmlshow; } foreach (glob("seqs/*.zip") as $seq){ if(isset($_GET['size'])) { $size=$splitter.filesize($seq); } $seq = explode("/", $seq); $seq=$seq[1]; print "seqs".$splitter.$seq.$size."\n".$htmlshow; } foreach (glob("sounds/*.zip") as $sound){ if(isset($_GET['size'])) { $size=$splitter.filesize($sound); } $sound = explode("/", $sound); $sound=$sound[1]; print "sounds".$splitter.$sound.$size."\n".$htmlshow; } } ?> <!-- End PHP generated content --> </body> </html> So right now my question to you PHP freaks is, can you please help me edit my script so I can search through a remote directory? *This* is one of the directories I wish to be able to search through & list.. Thanks in advance. Edit; It might help if you know what the site currently looks like. *Click* This topic has been moved to Linux. http://www.phpfreaks.com/forums/index.php?topic=318175.0 I'd like to use an application that's not browser based, on Internet Explorer. I've read somewhere that this is possible with a PHP script, but which one? If you can get me on the right track, I'd really appreciate it. Cheers. Okay im having a problem with cookies so if anyone can help i would be grateful. When you login you can choose how long to stay in for. For testing purposes the choices a Forever 1 Hour 1 Day Never Based on your choice i am setting the cookie expiration as follows: if ($_POST['remember_me'] == '1') { setcookie('remember', time() + 99999999999999); } elseif ($_POST['remember_me'] == '3600') { setcookie('remember', time() + 3600); } elseif ($_POST['remember_me'] == '84600') { setcookie('remember', time() + 84600); } elseif ($_POST['remember_me'] == '0') { setcookie('remember'); } echo $_COOKIE['remember']; } Then for testing I am echoing the cookie at the head of the document: echo "Cookie: " . @$_COOKIE['remember']; The problem is that when the browser is closed the cookie is gone. Only the last option "never" is set as a session cookie which means the others should stay active even when the browser is closed shouldnt they? Anything i have missed here? This has been driving me crazy for hours! I am trying to set a cookie: setcookie("username", $_POST['user']); And for a while it wasn't working, then it started randomly working. Now, when I try to use if(isset($_COOKIE['username'])) PHP is saying the cookie does not exist. PLEASE help! Thanks. Hey all, http://www.adamrowden.co.uk/photo-searchr.asp If you visit this link, you'll see on the left side you have a few photos. If you click a photo from that page and then go back to the link i've provided you'll see that it shows you your 'recently viewed photos'. I'm wanting to do exactly that and need some pointers on how i would!? I'd be very grateful for any help Thanks, Jimmy m i'm trying to set a cookie value to a result from a query, but its not working. all of the other cookies are being set, except for one. any ideas why? <?php //Checks if there is a login cookie if(isset($_COOKIE['ID_forum'])) //if there is, it logs you in and directs you to the members page { $username = $_COOKIE['ID_forum']; $pass = $_COOKIE['Key_forum']; $user_level = $_COOKIE['Forum_level']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check )) { if ($pass != $info['password']) { } else { header("Location: index.php"); } } } if (isset($_POST['submit'])) { // if form has been submitted // makes sure they filled it in if(!$_POST['username'] | !$_POST['pass']) { die(' <h2> You did not fill in all of the fields</h2> <p<a href="login.php">Return to login page</a> '); } // checks it against the database $check = mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error()); //Gives error if user dosen't exist $check2 = mysql_num_rows($check); if ($check2 == 0) { die(' <h2> That user does not exist in our database.<br/> </h2> <p<a href="login.php">Return to login page</a> '); } while($info = mysql_fetch_array( $check )) { $_POST['pass'] = mysql_real_escape_string($_POST['pass']); $info['password'] = mysql_real_escape_string($info['password']); $_POST['pass'] = md5($_POST['pass']); //gives error if the password is wrong if ($_POST['pass'] != $info['password']) { die(' <h2> Incorrect password, please try again</h2> <p<a href="login.php">Return to login page</a> '); } else { $_POST['username'] = mysql_real_escape_string($_POST['username']); $_POST['user_level'] = mysql_real_escape_string($_POST['user_level']); $hour = time() + 3600; setcookie(ID_forum, $_POST['username'], $hour); setcookie(Key_forum, $_POST['pass'], $hour); setcookie(Forum_level, $_POST['user_level'], $hour); //this cookie is not being set setcookie(test, 'test cookie', $hour); // testing that cookie is being set - this works header("Location: index.php"); $query2 = mysql_query("SELECT * FROM users WHERE username = ".$_POST['username'])or die(mysql_error()); setcookie(Level_forum, $query2['user_level'], $hour); } } } else { // if they are not logged in ?> //form code is here. i have not included it to save space <?php } ?> Thanks Hello all, I hope someone can shed some light/point me in the right direction. I have a site that allows you to search for a customer then view and change their detail. page 1 has a search box for name entry. page 2 displays all the matches retrieved from a db table that match. The user selects which customer is the correct 1 and sets a cookie containing the selected customers unique id. page 3 allows changing of the customers details. now the problem I have: If a user navigates to page 3 and has a customers details on page for viewing all is well. If they open a new tab (leaving page 3 open on first tab) and go to page 1, search for another customer, page 2 select another customer (which overwrites cookie) then to page 3. They now have two tabs open on page 3 both displaying different customer details. If they return to the first tab and change some detail, when they save it actually updates the users details that corrispond to the second tab. I know this is because the cookie has been changed that holds the unique id that is required for the update query. How can I prevent this? I've looked at sessions but it would seem the same issue would excist. Am I wrong? Many Thanks I hope I made sense. This is prob a stupid question.. but i've always wondered..
When deleting a cookie why do we use
why do we use:
setcookie($name, '', time() - 3600, "/", "", 0);
when this works just fine:
setcookie($name, '', 0, "/", "", 0);
isn't the time() just a waste of space?
I ask this because everywhere i look i see:
setcookie($name, '', time() -3600 , "/", "", 0);
I'm trying to write a script that allows the user to select their personal settings for the site. They can pick the color of their background, link color, link hover color and the header color. the first file is supposed to use the defaults, blue for the links, orange for the link hover color red for the background and blue for the header. the second file is supposed to configure the cookie variables to store the values entered by the user and the third file i'm supposed to modify the internal stylesheet to utilize the values stored in the session variables. I tried to set each of the values in file two but i think i messed it up. I dont know how to modify the stylesheet to accept and change to the values of the cookies...Please help here are the files file1.php Code: [Select] <?php //Handle the form if it has been submitted: if (isset($_POST['background_color'], $_POST['link_color'], $_POST['link_hover_color'], $_POST['header_color'])){ //send the cookies: setcookie('background_color', $_POST['background_color'], time()+10000000); setcookie('link_color', $_POST['link_color'], time()+10000000); setcookie('link_hover_color', $_POST['link_hover_color'], time()+10000000); setcookie('header_color', $_POST['header_color'], time()=10000000); //Message to be printed later: $msg = '<p>Your settings have been entered! Click <a href="file2.php">here</a> to see them in action.</p>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File1</title> <style type="text/css"> <!-- These are the styles the session (if it exists) should configure --> a:link {color:blue;} a:hover {color:orange;} body {background-color:red} h1 {color:blue; text-align:center;} </style> </head> <body> <?php //if the cookies were sent print a message if (isset($msg)){ print $msg; } ?> <div><p>Please complete this form to configure the appearance of this website:</p> <form action="File2.php" method="post"> <select name="background_color"> <option value="">Background Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_color"> <option value="">Link Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="link_hover_color"> <option value="">Link Hover Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <select name="header_color"> <option value="">Header Color</option> <option value="FF6600">Orange</option> <option value="CC00CC">Purple</option> <option value="FFFF00">Yellow</option> <option value="00FF00">Green</option> <option value="FF0066">Pink</option> <option value="000099">Blue</option> </select> <input type="submit" name="submit" value="Configure!" /> </form> </div> </body> </html> file2.php Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File2</title> </head> <body> <div> <?php include('file1.php'); //check for a background color if (isset($_COOKIE['background_color'])){ print "\body: #" . htmlentities($_COOKIE['background_color']) . ";\n"; }else{ print "\body: #c00"; } //check for a link_color if (isset($_COOKIE['link_color'])){ print "\a:link: #" . htmlentities($_COOKIE['link_color']) . ";\n"; }else{ print "\a:link: #00f"; } //check for a link_hover color: if (isset($_COOKIE['link_hover_color'])){ print "a\:hover: #" . htmlentities($_COOKIE['link_hover_color']) . ";\n"; } //Check for a header color if (isset($_COOKIE['header_color'])){ print "\h1: #" . htmlentities($_COOKIE['header_color']). ";\n"; } ?> Your settings have been updated. <a href="File3.php">Click here</a> to continue. <br /><br /> </div> </body> </html> file3.php Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>File3</title> <style type="text/css"> <!-- These are the styles the session should configure --> a:link {color:blue;} a:hover {color:orange;} body {background-color:red} h1 {color:blue; text-align:center;} </style> </head> <body> <div> <h1>Welcome to YOUR pretty website</h1> <a href = "File1.php">Click here</a> to go back and start over!</a> </div> </body> </html> I'm pretty sure i did in file2 what i was supposed to do in file3 im totally confused When a user logs in it sets a cookie with their user id and sets the time they choose(either a session cookie or a cookie lasting one year for users who wish to stay logged in). when they select to stay logged in forever and close the browser the next time they open it, it tells them they arent logged in. however when they go to a new page they appear to be logged in. What i dont understand is why they have to go to a new page for it to say they are logged in. Here is the code which runs everytime the site is load if (isset($_COOKIE['uid'])) { $user->setup($_COOKIE['uid']); } user setup basically selects their info from the database and sets their username and other info to variables. Anyone know a better way to do this? i was trying to make a new login script and wanted to make point system which i can add points manually to member so i made a new column and named it userpoint i tried many many codes First i used
$_SESSION['userName'] = $username; echo "Welcome ".$_SESSION['userName']."!"; $_SESSION['userpoint'] = $userpoint; echo "you got".$_SESSION['userpoint']."!";the page showed username but didn`t show the points ! i tried then i figured out cookies if(isset($_COOKIE['ID_my_site'])) { setcookie( "userpoint"); $username = $_COOKIE['ID_my_site']; $userpoint = $_COOKIE['ID_my_site']; $pass = $_COOKIE['Key_my_site']; $check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error()); while($info = mysql_fetch_array( $check)) {this time the page shows both of usernames without mentioning the points ! i changed $userpoint = $_COOKIE['ID_my_site'];to $userpoint = $_COOKIE['Key_my_site']; and it showed the hashed password i want to set a new $_COOKIE so i can get members point to member area is that possible ? the script is still missing secure and salt and the security stuff i`ll add them later i just want to know if is that possible Edited by Ahmedamer, 03 September 2014 - 09:39 PM. Hi guys, I am having a sticky problem with Cookies. Basically, I've had to change the settings of my CMS which has resulted in me now having the same cookie names for the cookie domains .domain.com and www.domain.com. I know I can just clear my cookies and the problem will be sorted, but it's not feasible for me to expect users of my site to clear their cookies. So my question is this. How can I delete the cookies created using www.domain.com with PHP? Everytime I set the expiry date of the cookies, it only applies it to those on .domain.com. Any help would be gratefully appreciated!! The code below is the only part of my script failing and I have no clue why. I even tried setting the TestCookie for 352 days. What boggles my mind is that this code used to work and is now failing. Has something changed? $value = "wtf"; setcookie("TestCookie",$value, time()+3600*24); setcookie("user", $name1, time()+14400); setcookie("userid", $uid1, time()+14400); setcookie("coid", $coid1, time()+14400); setcookie("login", "yes", time()+14400); setcookie("status", $status1, time()+14400); Im trying to use the following code; if($login_Remember) { /* Check if Remember Me was set */ setcookie('login_ID', $row['ID'], time()+3600 * 24 * 30); setcookie('login_Name', $row['Name'], time()+3600 * 24 * 30); setcookie('login_Access', $row['Value'], time()+3600 * 24 * 30); } header("Location: index.php"); When i try to use it, the only cookie thats registered is the bottom on "login_Access". None of the others are. I have tried everything but nothings working. I dont get any error messages. Using PHP v5.3.3 on IIS Please help. Thanks hi everybody ; its working Forgot Password i am posting a form.php to anohter page.php and if turn true i am sending mail and creating a cookie after header(Location: form.php) so cookie code in page.php Code: [Select] ob_start() sessioon_start $_COOKIE['mailsent'] = $mailii; setcookie("mailsent",$mailii,time()+(60*30)); i want show it Quote if(isset($_Cookie['mail'])) { echo "sent mail to $_Cookie['mailsent']" } but i am taking this Notice Quote Notice: Undefined index: kayip in J:\EasyPHP-5.3.2i\twww\site\form.php on line 133 when i lookup to site Cookies i am allready seem "mailsent" and value = $dynamic_mail so where am i doing wrong ?? |