Jump to content

westman

Members
  • Posts

    600
  • Joined

  • Last visited

Everything posted by westman

  1. westman

    cookie coding

    I put the setcookie on the http://mysite.com?p=dashboard page and it works just fine. Thank you everyone for your help. I am sure more questions shall come later 😉
  2. westman

    cookie coding

    I am using... echo "<script>setTimeout(\"location.replace('http://mysite.com?p=dashboard')\",1000)</script>"; at the bottom of my login script. What code can I use where a cookie will be set and I can move my user to a different page? Just testing this code and its not the issue.
  3. westman

    cookie coding

    back to the same problem. It works fine on a blank document but when I put the setcookie code in with my login script the cookie does not set and I get the error about headers again.
  4. westman

    cookie coding

    OMG thank you so much it is working. Polly got a cookie. I put the set cookie at the top of the page and not in the body.
  5. westman

    cookie coding

    I am trying so hard to understand, I am. If someone could provide code of a working example that would be grate to understand from there. I now have this code on one page of my site... setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE); and this code on a different page... if(isset($_COOKIE['username'])){ echo "1"; }else{ echo "0"; } my output is 0 every time. I am not successful at setting my first cookie
  6. westman

    cookie coding

    I have played around with it some more but still get an error when only the line of code to set the cookie is there. Also the line of code "echo" never works for me. What am I doing wrong?
  7. westman

    cookie coding

    Error update. Using this code... $new_cookie = "123456789abcdefg"; setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE); echo $_COOKIE["username"]; echo "<br />"; print_r($_COOKIE); the output is still an error.
  8. westman

    cookie coding

    I have a problem creating my first cookie. I keep getting this error message and when I use... echo $_COOKIE["username"]; I get nothing on the screen.
  9. westman

    cookie coding

    thank you so much.
  10. westman

    cookie coding

    Thank you. What happens to the cookie when it hits 30 days old from my script?
  11. westman

    cookie coding

    I see, so to give my cookie an updated value will this code work? setcookie("username", $old_cookie, strtotime( '-30 days' ), "/", "", "", TRUE); setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE);
  12. westman

    cookie coding

    Hi all, I am coding cookies for the first time and here is what I have. setcookie("username", $old_cookie, "1", "/", "", "", TRUE); setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE); Is this the right way of resetting the value of one cookie? ps. I did read a lot on http://php.net/manual/en/function.setcookie.php but it is not clear.
  13. I was thinking of having 1 cookie array that has email, password, and id inside or should I use one cookie for each value?
  14. would this code be a good way of keeping my users logged in for a long time? if (isset($_SESSION['id'])) { // check to see if user in logged in with session // user continuous to be logged in code goes here } else if (isset($_COOKIE["id"])) { // if user session has ended but they still have a cookie // auto login code goes here }else{ // send user to login page }
  15. well how does Gmail and Facebook keep your sessions open for a very long time? if I use... ini_set('session.gc_maxlifetime', 86400); session_set_cookie_params(86400); session_start(); is it bad practice for keeping a session for a day?
  16. Hi everyone, I would like my sessions to time out after 7 days but they only last 30 minutes. I am using php 7. Here is what I have... php.ini - I always keep this file on the server ;register_globals = off ;allow_url_fopen = On ;expose_php = Off ;max_input_time = 60 ;variables_order = "EGPCS" ;extension_dir = ./ ;upload_tmp_dir = /tmp ;precision = 12 ;SMTP = relay-hosting.secureserver.net ;url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset=" ;memory_limit = 51M ;post_max_size = 10M ;file_uploads = On upload_max_filesize = 7M ;max_execution_time = 7200 ;max_input_time = 7200 session.gc_maxlifetime = 21800 ; Only uncomment zend optimizer lines if your application requires Zend Optimizer support ;[Zend] ;zend_optimizer.optimization_level=15 ;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3 ;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3 ;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/ZendExtensionManager.so ;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/ZendExtensionManager_TS.so ; -- Be very careful to not to disable a function which might be needed! ; -- Uncomment the following lines to increase the security of your PHP site. ;disable_functions = "highlight_file,ini_alter,ini_restore,openlog,passthru, ; phpinfo, exec, system, dl, fsockopen, set_time_limit, ; popen, proc_open, proc_nice,shell_exec,show_source,symlink" phpinfo.php - I never keep this file on the server session Session Support enabled Registered save handlers files user Registered serializer handlers php_serialize php php_binary Directive Local Value Master Value session.auto_start Off Off session.cache_expire 180 180 session.cache_limiter nocache nocache session.cookie_domain no value no value session.cookie_httponly Off Off session.cookie_lifetime 0 0 session.cookie_path / / session.cookie_secure Off Off session.gc_divisor 100 100 session.gc_maxlifetime 21800 21800 session.gc_probability 1 1 session.lazy_write On On session.name PHPSESSID PHPSESSID session.referer_check no value no value session.save_handler files files session.save_path no value no value session.serialize_handler php php session.sid_bits_per_character 4 4 session.sid_length 32 32 session.upload_progress.cleanup On On session.upload_progress.enabled On On session.upload_progress.freq 1% 1% session.upload_progress.min_freq 1 1 session.upload_progress.name PHP_SESSION_UPLOAD_PROGRESS PHP_SESSION_UPLOAD_PROGRESS session.upload_progress.prefix upload_progress_ upload_progress_ session.use_cookies On On session.use_only_cookies On On session.use_strict_mode Off Off session.use_trans_sid 0 0 php session_start(); $_SESSION['id'] = $id; how do I get my sessions to last longer that 30 minutes?
  17. westman

    photo files

    lol, that's funny. it is the last line... var_dump($pic_array); that is printing to the page. How do I stop it and still have the code working?
  18. westman

    photo files

    Last question on this. $pic_array = array_diff($pic_array, $remove); var_dump($pic_array); is printing the following to my page array(5) { [0]=> string(1) "1" [2]=> string(1) "3" [3]=> string(1) "4" [4]=> string(1) "5" [5]=> string(1) "6" } How do I stop it printing to my page?
  19. westman

    photo files

    thank you so much.
  20. westman

    photo files

    Thank you so much for the examples. few more questions. In my DB my array looks like 1,2,3,4,5,6,7,8,9 not 1, 2, 3, 4, 5, 6, 7, 8, 9 Is that a problem? also can I change $remove = [6]; to $number_to_drop = '6'; $remove = [$number_to_drop]; ?
  21. westman

    photo files

    Just got to the removing stage of my coding. How do I find number 6 in my array and remove it? $pic_array = "1,2,3,4,5,6,7,8,9"; $remove = "6"; if (in_array($remove, $pic_array)) { // ??? }
  22. westman

    photo files

    I found a method, coded it and it works. Every image uploaded I added to an array I put in the DB. Looking like this; 1,2,3,4,5,7,8,9 To view the images I used this... $pic_array = explode(",", $pic); foreach ($pic_array as $key => $value) { $check_pic_array = 'pro_images/'.$id.'/pro'.$value.'.jpg'; if (file_exists($check_pic_array)) { $pic = '<img src="$check_pic_array" style="max-width:100px; max-height:100px;" border="1">'; } } As you can see number 6 is missing. With this method it is easy to locate and remove unwanted files from the DB and server. Thank you for your help.
  23. westman

    photo files

    This is how I started the needed code but it is not working $directory = 'pro_images/'.$id.'/casual'; if (file_exists($directory) && is_dir($directory)) { $scanned_directory = array_diff(scandir($directory), array('..', '.')); } $scanned_directory2 = explode(",", $scanned_directory); echo $scanned_directory2; any help?
  24. westman

    photo files

    I have files that users upload. 1.jpg 2.jpg 3.jpg etc. what if the best way of finding out what _.jpg are in a folder as users may delete an image.
×
×
  • Create New...