Current location: Hot Scripts Forums » Programming Languages » PHP » [ COOKIES ] Get's deleted on restart...


[ COOKIES ] Get's deleted on restart...

Reply
  #1 (permalink)  
Old 03-05-04, 05:53 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
[ COOKIES ] Get's deleted on restart...

Code:
setcookie($cookiename . 'hits', serialize($client_ip), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
Okay the code above stores an ip and blaa bla, and I wanted it so that it does not get deleted automatically...ever (like a remember me password cookie type).

But it seems that it get's deleted automatically if i close my browser and start it up again... Is there a way to make this not happne, and to make it perment (like a remember password cookie?)


Thank you,
Nazu
Reply With Quote
  #2 (permalink)  
Old 03-05-04, 09:44 PM
jerry's Avatar
jerry jerry is offline
Newbie Coder
 
Join Date: Mar 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Here's the solution

setcookie($cookiename . 'hits', serialize($client_ip), Time()+63072000, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);


The third field is the time the cookie expires. You left it to zero (0) in your code. Time() refers to the current time in seconds, adding the long digit there will set the expiry to two years ahead of the current time.

Hope that helps.
__________________
<font face="Verdana"><a href="http://www.generalscripting.com">General Scripting</a> Web Development Services</font>
Reply With Quote
  #3 (permalink)  
Old 03-05-04, 10:01 PM
Infinite_Hackers's Avatar
Infinite_Hackers Infinite_Hackers is offline
Coding Addict
 
Join Date: Dec 2003
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Well im trying to check for unique hits on my site [ http://gfx-pro.ath.cx ]

and im having a bit of a problem, any clues on how to make a good unique hit counter?

PHP Code:

//

// Here we are going to get the site's unique hits.
//

$client_ip  getenv(REMOTE_ADDR);   // Get's the clients ip address
$client_ip encode_ip($client_ip);
$page $_SERVER["REQUEST_URI"]; // get the page the user is at

if($page == '/') {         //
   
$page '/index.php';   // The page
}                          //


$sql "SELECT * FROM " .UNIQUE_HITS_TABLE;
$result mysql_query($sql);

while( 
$row mysql_fetch_array($result) ) {
    
$hits[] = $row;
}

if( !
$total_hits count($hits) ) {
    
$is_unique false;
}

$is_unique true;

if(
$is_unique != false) {
    for(
$i 0$i $total_hits$i++)
    {   
       
$rec_id $hits[$i]['hits_id'];
       
$rec_ip $hits[$i]['hits_ip'];
       
$rec_page $hits[$i]['hits_page'];

    }

       if( !isset(
$HTTP_COOKIE_VARS['unique_hits']) && $client_ip != decode_ip($rec_id) ) {

           
setcookie('unique_hits'$userdata['session_id'], Time()+63072000$cookiepath$cookiedomain$cookiesecure);

           
$sql "INSERT INTO " UNIQUE_HITS_TABLE " (hits_ip, hits_page)
                  VALUES ('" 
str_replace("\'""''"$client_ip) . "', '" str_replace("\'""''"$page) . "')";

            if( !
$result $db->sql_query($sql) )
            {
                
$is_unique false;
            }

            
$is_unique true;
            
$set_unique $total_hits;


       } else {
         
$is_unique false;
         
          
$set_unique $total_hits;
          if(
$set_unique == '') {
              
$set_unique 0;
          }

       }

} else {
    
$set_unique '0';

is something that im using at the moment, it's not that good i think :S.

Last edited by Infinite_Hackers; 03-05-04 at 10:04 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Thinkin about cookies.... dcooldude_1 HTML/XHTML/XML 2 03-08-04 09:44 AM
cookies....how do I use them?? cwg25 HTML/XHTML/XML 5 03-05-04 10:25 AM
Setting cookies - if/else FayeC ASP 0 01-29-04 11:45 PM
Delete cookies regardless of case. AussierulesOK JavaScript 1 11-08-03 10:15 AM
Can't seem to get the cookies to the cookie_jar benny666 Perl 1 10-28-03 04:54 AM


All times are GMT -5. The time now is 09:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.