Jump to content

Pi_Mastuh

Members
  • Posts

    233
  • Joined

  • Last visited

    Never

Everything posted by Pi_Mastuh

  1. I've been working with cookies and have made errors in setting them causing them to make weird things happen on my site. Is there a way that for a user going to a page, it deletes every cookie set for the specific domain?
  2. So I set the cookie on the page that creates the session, making the cookie value the session? $cookieName="preuserName"; $cookieVal="$_SESSION['preuserName']"; $cookieExp=time()+(60*60*24*31); //All the values set, now to call the function; setcookie($cookieName,$cookieVal,$cookieExp); $cookieName2="preuserID"; $cookieVal2="$_SESSION['preuserID']"; $cookieExp2=time()+(60*60*24*31); //All the values set, now to call the function; setcookie($cookieName2,$cookieVal2,$cookieExp2); How does it tell it to get the session from the cookie once the user closes the browser and goes back another time? I can't find anything on that.
  3. How do I use the cookies? I can never get them to work with the sessions.
  4. When a user logs in on my site it goes session_start(); session_register('preuserName'); session_register('preuserID'); $session=session_id(); But when the user closes the browser they have to relogin. How would I make them never expire, until the user logs out that is, and when they go to the main page (index.php) it re-directs to another page if it finds the session?
  5. I need to know what each letter equals as a number, for example it could be ABCDE is 12345 so 12345*4=54321 (Not the answer though)
  6. It's not homework, it's something I'm working on for my site.
  7. I'm trying to solve this equation with php for loops. Each letter represents a number and i need to figure out what each letter represents as a number.
  8. How would I make a script using for loops to figure out this equation: EDCBA x 4 = ABCDE Each letter represents a number and i need to know what ABCDE is. Anyone know?
  9. I had a script that worked and everything but all of a sudden it just stopped working, it doesn't do anything. I think it has somethin to do with the database. Does anyone have an idea what might have happened?
  10. I tried using cookies but they wouldn't delete when the user logged out. It had trapped users in.
  11. I have the sessions carried to each page, but they end when the user closes the browser or leaves the site. I want it to keep them logged in until they log out.
  12. When the user logs in on my site it uses session_start(); session_register('preuserName'); session_register('preuserID'); $session=session_id(); mysql_query("UPDATE chibifriends SET userLastLogin = '$today' WHERE preuserID = '$preuserID'"); to log them in. How would I make the sessions not expire and when they go to the site (index.php) re-direct to another page if they're logged in?
  13. If I put each avatar each user has unlocked in the table it'll get really big really fast, won't it? Especialy when I get more users and as I add more avatars.
  14. I want to create a feature to allow users to unlock avatars, by doing things on the site, to use on my site's forums. However I can't think of a way to do so without taking up a huge amount of my limited database space. I do have a 2nd database I can use but i don't know how to use 2 in 1 site. Any ideas for how I can make this work? ???
  15. How would I run a query that tells it to select 5 random rows that meet the criteria?
  16. I'm trying to make my messageboard replies sort with the newest post at the bottom. How would I do that? ///////////////////////////////////////////// // R E P L I E S ///////////////////////////////////////////// // look for howmany rows have this replyToID //////////////////////////////////////////////////// include ("secure/config.php"); /////////////////////////////////////////////////////////// $sql_repliessearch = "SELECT chibishopboard.messageID, chibishopboard.message, chibishopboard.replyToID, chibishopboard.title, chibishopboard.preuserID, chibishopboard.preuserName FROM chibishopboard WHERE chibishopboard.replyToID='".$HTTP_GET_VARS['messageID']."'"; $result_sql_repliessearch = mysql_query($sql_repliessearch, $connection); $numReplies = mysql_numrows($result_sql_repliessearch); for($i=0; $i<$numReplies; $i++) { $messageID = mysql_result($result_sql_repliessearch,$i,"messageID"); $message = mysql_result($result_sql_repliessearch,$i,"message"); $currentpreuserID = mysql_result($result_sql_repliessearch,$i,"preuserID"); // get username //////////////////////////////////////// include ("secure/config.php"); /////////////////////////////////////////////////// $sql_preusersearch = "SELECT chibifriends.preuserID, chibifriends.preuserName FROM chibifriends WHERE chibifriends.preuserID='".$currentpreuserID."'"; $currentpreuserName = mysql_result(mysql_query($sql_preusersearch, $connection), 0, "preuserName"); $sql = "SELECT * from chibifriends where preuserName ='$currentpreuserName'"; $result = mysql_query($sql, $connection); $numShop = mysql_num_rows($result); $query_data =mysql_fetch_array($result); $currentAvvie = $query_data['avvie']; $currentGender = $query_data['gender']; $currentSiggy = $query_data['siggy']; // find profileID for linking // mike $sql_profilesearch = "SELECT profiles.preuserID, profiles.profileID FROM profiles WHERE profiles.preuserID='".$currentpreuserID."'"; // mike $profileID = @mysql_result(mysql_query($sql_profilesearch, $connection), 0, "profileID"); $getsmileys = mysql_query("SELECT * from smileys"); while($rgsmileys = mysql_fetch_array($getsmileys)) { extract($rgsmileys); $message = str_replace("$smiley_before", "<img src='$smiley_after'>", $message); } echo '<tr> <td width="*" bordercolor="#FF9900" bgcolor="#3366FF"> <p align="center"><font color="#FFFFFF">Reply by: '.$currentpreuserName.'<br>'.$currentGender.'<br><br><img src='.$currentAvvie.'></font></td> <td width="*">'.$message.''; if (isset($currentSiggy)) { echo '<br><hr>'.$currentSiggy.'</td></tr>'; } else { echo '</td></tr>'; } } ?>
  17. Nevermind I got it working, I had a typo in the cookie name. Thank you :).
  18. I tried that and it didn't work. It still finds the cookie ???
  19. I'm using a code that when you go to my site it re-directs to another page, home.php, if it finds cookies. Otherwise is creates them when you login. I've got it to find the cookies and re-direct but when I hit logout it just re-directs back to home.php, which means the user is logged in forever. I can't get them to delete. Any ideas?
  20. My entire script, including all the stuff that was there before is [code]<?php session_start(); include("secure/config.php");   session_unregister('preuserName');   session_unregister('preuserID'); session_unregister('image'); session_destroy(); define ( 'COOKIE_PATH', '/' ); define ( 'COOKIE_EXPIRE', time () - 86400 ); define ( 'COOKIE_SECURE', false ); // for for global domain access use .your_domain.com, instead of $_SERVER['SERVER_NAME'] define ( 'COOKIE_DOMAIN', $_SERVER['SERVER_NAME'] ); function cookie_remove () { if ( ! empty ( $_COOKIE ) ) { foreach ( $_COOKIE AS $k => $v ) { set_cookie ( $k ); } } } function set_cookie ( $name, $value = '', $expire = COOKIE_EXPIRE, $path = COOKIE_PATH, $domain = COOKIE_DOMAIN, $secure = COOKIE_SECURE ) { header ( 'Set-Cookie: ' . $name . '=' . $value . '; expires=' . ( $expire == 0 ? 0 : gmdate ( 'D, d-M-Y H:i:s \G\M\T', $expire ) ) . '; path=' . $path . '; domain=' . $domain . ( $secure ? '; secure;' : '' ), false ); } set_cookie ( 'preuserID' ); set_cookie ( 'preuserName' ); header("Location: ../"); exit; ?> [/code]
  21. It's just re-directing back to home.php again, which means the cookies aren't being deleted ???
  22. I put it in the page and got Parse error: parse error, unexpected '(' in /homepages/20/d175171605/htdocs/reg/logout.php on line 19 Did I do it right? [code]function cookie_remove () { if ( ! empty ( $_COOKIE ) ) { foreach ( $_COOKIE AS $k => $v ) { set_cookie ( $k ); } } } function set_cookie ( $name, $value = '', $expire = ( time ( ) - 86400 ), $path = '/', $domain = $_SERVER['SERVER_NAME'], $secure = false ) { header ( 'Set-Cookie: ' . $name . '=' . $value . '; expires=' . ( $expire == 0 ? 0 : gmdate ( 'D, d-M-Y H:i:s \G\M\T', $expire ) ) . '; path=' . $path . '; domain=' . $domain . ( $secure ? '; secure;' : '' ), false ); } set_cookie ( 'preuserID' ); set_cookie ( 'preuserName' );[/code]
  23. Like this? header(setcookie ("preuserID", "", time() - 60*60*24*100) (setcookie ("preuserName", "", time() - 60*60*24*100) ("Location: ../")));
  24. [quote author=printf link=topic=123447.msg510246#msg510246 date=1169435565] You can't unset a $_COOKIE with unset();, it will only remove the scope of the local GLOBAL variable, not remove it from the browser instance! Also don't use setcookie() if your redirecting, because not all browsers will set the cookie, if a redirect is issued in the same header! Use header(Set-Cookie:...) to set a cookie when redirecting, it's 100% cross browser safe, which setcookie() is not! printf [/quote] How do I do that?
  25. I'm using IE. And i don't know why it wasn't working, it's still re-directing and it only does that if the cookies are found.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.