karker Posted May 6, 2011 Share Posted May 6, 2011 how can i set cookie like a*dm*n@**t*r*c**.*c** ?? $cookkiee = $islem_1['mail'] ; $sayisi = strlen($cookkiee)-1 ; $cok = $islem_1['mail'] ; for($i=0;$i<=$sayisi;$i++) { $sifr = rand(0,2); if($sifr ==0) { $cok[$i]= '*'; } $dizik = $cok[$i]; setrawcookie("kayip",$dizik,time()+(60*30),"/"); $_COOKIE['kayip'] = $dizik; echo $dizi // etc . a*dm*n@**t*r*c**.*c** } echo $_COOKIE['kayip']; // etc. just one char being like random a Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/ Share on other sites More sharing options...
fugix Posted May 6, 2011 Share Posted May 6, 2011 i honestly have no clue what you are asking Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211566 Share on other sites More sharing options...
karker Posted May 6, 2011 Author Share Posted May 6, 2011 i want create a cookie like a*s*das**as@*as*e**sd.c** with upses codes Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211600 Share on other sites More sharing options...
xyph Posted May 6, 2011 Share Posted May 6, 2011 Do you want that to be your cookie value? Or cookie name? You should simply be able to use setcookie('cookie_name', 'a*s*das**as@*as*e**sd.c**'); Assuming output hasn't been sent to the browser. Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211605 Share on other sites More sharing options...
karker Posted May 6, 2011 Author Share Posted May 6, 2011 $cookkiee = $islem_1['mail'] ; // mail in here [email protected] $sayisi = strlen($cookkiee)-1 ; $cok = $islem_1['mail'] ; for($i=0;$i<=$sayisi;$i++) { $sifr = rand(0,2); if($sifr ==0) { $cok[$i]= '*'; } $dizik = $cok[$i]; setrawcookie("kayip",$dizik,time()+(60*30),"/"); $_COOKIE['kayip'] = $dizik; echo $dizi } echo $_COOKIE['kayip']; Cookie setting like "m" or a char"" didnt be cookie like "as*asd*@as*as*.co*" why for ? can everybody help me? Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211611 Share on other sites More sharing options...
karker Posted May 6, 2011 Author Share Posted May 6, 2011 ?? Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211630 Share on other sites More sharing options...
wildteen88 Posted May 6, 2011 Share Posted May 6, 2011 You are not making any sense at all. Please explain what you are trying to do. Are you trying to set a cookie so it stores an email address? Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211638 Share on other sites More sharing options...
xyph Posted May 6, 2011 Share Posted May 6, 2011 I see what's going on here. I suggest using whitespace to help you organize your code. Also, rewrite it to make it easier to understand. <?php $mail = '[email protected]'; $mail_obs = ''; foreach (str_split($mail) as $chr ) { if( mt_rand(0,2) === 0 ) $chr = '*'; $mail_obs .= $chr; } echo $mail_obs; ?> Hope that helps. Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211641 Share on other sites More sharing options...
karker Posted May 6, 2011 Author Share Posted May 6, 2011 i did but $mail = '[email protected]'; i must do strlen($mail)-1 and for incoming mail witdhs are dynamical ? how can we upgrade it ? Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211661 Share on other sites More sharing options...
xyph Posted May 6, 2011 Share Posted May 6, 2011 str_split( $string ) will split a string into an array, and will be dynamic. If you wanted to be ultra-efficient, you would use: $mail = '[email protected]'; for($i=0;$i<strlen($mail);$i++) { if( mt_rand(0,2) === 0 ) $mail[$i] = '*'; } echo $mail; But the difference is MINIMAL. You are also permanently changing the $mail variable. Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211663 Share on other sites More sharing options...
karker Posted May 6, 2011 Author Share Posted May 6, 2011 thankx xyph for helping Link to comment https://forums.phpfreaks.com/topic/235718-set-cookie/#findComment-1211680 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.