Jump to content

westman

Members
  • Content count

    580
  • Joined

  • Last visited

Everything posted by westman

  1. westman

    user agreement

    Hi all, No PHP or cookies today just text. I would like to update my Terms of Use / User Agreement - legal page. I am terrible with page content like this and would like to use a good free template. Where do I go for this?
  2. 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.
  3. westman

    cookie coding

    Thank you for the answer to my question. Most of what you were discussing I did not follow but thanks.
  4. westman

    cookie coding

    In my last topic i opened It was advised to have a new cookie and never use the same one. At the moment my code is setting a new cookie with each page view after being logged in. Is this too excessive?
  5. westman

    cookie coding

    Hi Foxy, Thank you very much for your contribution. I was really quite advance for me but I am sure it wasn't lost on others. In the end I added one more line of code to fix the problem - It probably didn't fix the problem but no errors are show to the page and the cookie gets killed. if (isset($_GET['active'])) { $active = $_GET['active']; if ($active == "logout"){ if(isset($_COOKIE["username"])){ setcookie("username", '', strtotime( '-5 days' ), '/'); } session_destroy(); echo "<script>setTimeout(\"location.replace('http://mysite.com')\",1000)</script>"; exit(); } } as you can see a just added "exit();"
  6. westman

    cookie coding

    Okay I got the biggest puzzle since early man. here is my code.. if (isset($_GET['active'])) { $active = $_GET['active']; if ($active == "logout"){ if(isset($_COOKIE["username"])){ setcookie("username", '', strtotime( '-5 days' ), '/'); } session_destroy(); // This code removes the cookie no problem. However it shows the header error echo "<script>setTimeout(\"location.replace('http://mysite.com')\",1000)</script>"; // this code does not show the header error but need to run the url (mysite/?active=logout) twice to kill the cookie (session destroy works just fine) header("location: http://www.mysite.com"); } } What do I do here?
  7. 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 😉
  8. 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.
  9. 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.
  10. 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.
  11. 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
  12. 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?
  13. 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.
  14. 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.
  15. westman

    cookie coding

    thank you so much.
  16. westman

    cookie coding

    Thank you. What happens to the cookie when it hits 30 days old from my script?
  17. 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);
  18. 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?
  19. westman

    session times: php.ini and phpinfo.php

    I was thinking of having 1 cookie array that has email, password, and id inside or should I use one cookie for each value?
  20. westman

    session times: php.ini and phpinfo.php

    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 }
  21. westman

    session times: php.ini and phpinfo.php

    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?
  22. 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.
  23. westman

    photo files

    lol. got it!
  24. 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?
  25. 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?
×