logo
down
shadow

PHP week cookies gone in few hours


PHP week cookies gone in few hours

By : mebs
Date : November 15 2020, 06:54 AM
it should still fix some issue
For starters, your if clauses are redundant, making it harder to inspect the workflow, fur us as well as for you.
code :
if (isset($_POST['remember']))
{
    $checkbox = 'remember_me';
}
if($checkbox == 'remember_me')
elseif (!$_POST['remember'])
<input type="hidden" name="remember" value="0" />
<input type="checkbox" name="remember" id="remember" value="1" checked />
$do_remember = isset($_POST['remember']);
//Use a timespan of 1 week
$remembering_timespan = time() + 7 * 24 * 60 * 60;
if ($do_remember)
{
    setcookie('remember_me', $_POST['username'], $remembering_timespan);
} else {
    //This is where i don't see why you are deleting a cookie
}


Share : facebook icon twitter icon
how do i get the sum of hours less than given year and week

how do i get the sum of hours less than given year and week


By : Nicola Nardin
Date : March 29 2020, 07:55 AM
Hope that helps I have the following table
code :
SELECT sum(hours) WHERE (year = 2015 AND week < 25) OR year < 2015
Add working hours to correct price category based on week day and hours + holiday

Add working hours to correct price category based on week day and hours + holiday


By : Igor Kopman
Date : March 29 2020, 07:55 AM
it should still fix some issue I want to bind the correct amount of hours to correct work period. The work week is from Monday to Sunday. Based on the time of the day the work has different price. The work price based on time of the day when is done are called Periods. We are using 24 hours time format. , Working example:
code :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;

public class Program
{
    public static void Main( string[] args )
    {
        var periods = new List<Period> {
            new Period( "1", Days.Workdays, TimeSpan.FromHours(0), TimeSpan.FromHours(7) ),
            new Period( "2", Days.Workdays, TimeSpan.FromHours(7), TimeSpan.FromHours(20) ),
            new Period( "3", Days.Workdays, TimeSpan.FromHours(20), TimeSpan.FromHours(22) ),
            new Period( "4", Days.Workdays, TimeSpan.FromHours(22), TimeSpan.FromHours(24) ),
            new Period( "5", Days.Weekend, TimeSpan.FromHours(0), TimeSpan.FromHours(7) ),
            new Period( "6", Days.Weekend, TimeSpan.FromHours(7), TimeSpan.FromHours(22) ),
            new Period( "7", Days.Weekend, TimeSpan.FromHours(22), TimeSpan.FromHours(24) ),
            new Period( "8", Days.Holiday, TimeSpan.FromHours(0), TimeSpan.FromHours(24) ),
        };
        var holidays = new List<DateTime> {
            new DateTime( 2017, 1, 1 ),
            new DateTime( 2017, 1, 3 ),
            new DateTime( 2017, 1, 6 ),
        };

        var sc = new ShiftCalculator( periods, holidays );

        var shiftperiods = sc.GetShiftPeriods( new DateTime( 2016, 12, 31, 22, 00, 00 ), new DateTime( 2017, 01, 07, 08, 00, 00 ) ).ToList();

        foreach ( var sp in shiftperiods )
        {
            Console.WriteLine( "{0} - {1} - {2} - {3:00.00}h", sp.Period.Name, sp.Period.Days, sp.Start, sp.Duration.TotalHours );
        }

    }
}

[Flags]
enum Days : byte
{
    Sunday = 1,
    Monday = 2,
    Tuesday = 4,
    Wednesday = 8,
    Thursday = 16,
    Friday = 32,
    Saturday = 64,
    Holiday = 128,

    Workdays = Monday | Tuesday | Wednesday | Thursday | Friday,
    Weekend = Saturday | Sunday,
}

[DebuggerDisplay("{Name}: {Days} ({Start}-{End})")]
class Period
{
    public Period( string name, Days days, TimeSpan start, TimeSpan end )
    {
        if ( days.HasFlag( Days.Holiday ) && days != Days.Holiday )
            throw new ArgumentException( "days" );

        if ( start > end )
            throw new ArgumentException( "end" );

        Name = name;
        Days = days;
        Start = start;
        End = end;
    }

    public string Name { get; private set; }
    public Days Days { get; private set; }
    public TimeSpan Start { get; private set; }
    public TimeSpan End { get; private set; }
}

class ShiftPeriod
{
    public Period Period { get; set; }
    public DateTime Start { get; set; }
    public TimeSpan Duration { get; set; }
}

class ShiftCalculator
{
    private readonly List<Period> _periods;
    private readonly List<DateTime> _holidays;

    public ShiftCalculator( IEnumerable<Period> periods, IEnumerable<DateTime> holidays )
    {
        _periods = periods.ToList();
        _holidays = holidays.Select( e => e.Date ).ToList();
    }

    public IEnumerable<ShiftPeriod> GetShiftPeriods( DateTime start, DateTime end )
    {
        if ( start > end ) throw new ArgumentException( "end" );

        var current = start;

        while ( current < end )
        {
            var period = GetPeriodByDateTime( current );

            var next = current.Date + period.End;

            if ( next > end )
            {
                next = end;
            }

            yield return new ShiftPeriod
            {
                Period = period,
                Start = current,
                Duration = next - current,
            };

            current = next;
        }

    }

    private Days GetDayFromDateTime( DateTime datetime )
    {
        Days day;
        if ( _holidays.Contains( datetime.Date ) )
        {
            day = Days.Holiday;
        }
        else
        {
            switch ( datetime.DayOfWeek )
            {
                case DayOfWeek.Sunday:
                day = Days.Sunday;
                break;
                case DayOfWeek.Monday:
                day = Days.Monday;
                break;
                case DayOfWeek.Tuesday:
                day = Days.Tuesday;
                break;
                case DayOfWeek.Wednesday:
                day = Days.Wednesday;
                break;
                case DayOfWeek.Thursday:
                day = Days.Thursday;
                break;
                case DayOfWeek.Friday:
                day = Days.Friday;
                break;
                case DayOfWeek.Saturday:
                day = Days.Saturday;
                break;
                default:
                throw new InvalidOperationException();
            }
        }
        return day;
    }

    private Period GetPeriodByDateTime( DateTime datetime )
    {
        var day = GetDayFromDateTime( datetime );
        var timeOfDay = datetime.TimeOfDay;
        var period = _periods.Where(
            e => e.Days.HasFlag( day ) && e.Start <= timeOfDay && e.End > timeOfDay )
            .FirstOrDefault();
        if ( period == null )
        {
            throw new InvalidOperationException();
        }
        return period;
    }
}
7 - Weekend - 12/31/2016 10:00:00 PM - 02.00h
8 - Holiday - 1/1/2017 12:00:00 AM - 24.00h
1 - Workdays - 1/2/2017 12:00:00 AM - 07.00h
2 - Workdays - 1/2/2017 7:00:00 AM - 13.00h
3 - Workdays - 1/2/2017 8:00:00 PM - 02.00h
4 - Workdays - 1/2/2017 10:00:00 PM - 02.00h
8 - Holiday - 1/3/2017 12:00:00 AM - 24.00h
1 - Workdays - 1/4/2017 12:00:00 AM - 07.00h
2 - Workdays - 1/4/2017 7:00:00 AM - 13.00h
3 - Workdays - 1/4/2017 8:00:00 PM - 02.00h
4 - Workdays - 1/4/2017 10:00:00 PM - 02.00h
1 - Workdays - 1/5/2017 12:00:00 AM - 07.00h
2 - Workdays - 1/5/2017 7:00:00 AM - 13.00h
3 - Workdays - 1/5/2017 8:00:00 PM - 02.00h
4 - Workdays - 1/5/2017 10:00:00 PM - 02.00h
8 - Holiday - 1/6/2017 12:00:00 AM - 24.00h
5 - Weekend - 1/7/2017 12:00:00 AM - 07.00h
6 - Weekend - 1/7/2017 7:00:00 AM - 01.00h
Crontab to run at two hours out of the day, but for one of those hours exclude certain days of the week

Crontab to run at two hours out of the day, but for one of those hours exclude certain days of the week


By : user2850406
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The easiest answer is going to be two separate entries in your crontab:
code :
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

 * 2,20 *  *  0,1,3,5,6 root /path/to/command.sh
 *  20  *  *  2,4       root /path/to/command.sh
Check if date is between hours interval or week-end. If not, calculate how many hours left until available hour

Check if date is between hours interval or week-end. If not, calculate how many hours left until available hour


By : Abbad Vakil
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Have you considered refactoring your code by using the DateTime class? It's compatible with PHP 5.2+ and it's usually the recommended way of dealing with dates in PHP.
Convert hours into week,days,hours in laravel 4.2

Convert hours into week,days,hours in laravel 4.2


By : steek
Date : March 29 2020, 07:55 AM
I hope this helps you . The following code will convert number of hours onto the expression you need:
Related Posts Related Posts :
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • Error with the ereg_replace
  • Getting the fields attached to a bundle of an entity in Drupal
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • What's wrong with my PHP Script? T_String issue
  • how to call a function of another file without including that file
  • is_rgb function in php
  • transform the numbers to letters using php
  • How to catch an exception from another class method PHP
  • PHP exec is blocked by ISP
  • PHP4 to PHP5 migration character encoding. latin1 vs utf8
  • Begin Transaction not defined
  • How much harm can a user do with xss on a page unique to them?
  • How to import data from a php file to javascript variable
  • PHP and Javascript - log complete workflow
  • When I echo !!! 0 it gives me a strange result
  • jquery ajax post dies after submit
  • How to upload file with curl on sftp server
  • Advanced search using a text input to search through only one category
  • Why do I get "Non-static method App\Models\Category::products() should not be called statically" in laravel
  • Stop notices from undefined indexes in arrays
  • PHP Excel Error when entering SUM function to a cell
  • laravel 4 eloquent eager load relation count
  • click submit in html and run php code
  • Extremely frustrating behavior with Internet Explorer, Bootstrap and Respond.js
  • Vkontakte vtag issues
  • Divide the number to a correct decimal
  • mysqli_insert_query not working
  • How to make a sitemap using zend framework 1
  • Laravel: array to Model with relationship tree
  • $_SERVER['DOCUMENT_ROOT'] vs $path = $_SERVER['DOCUMENT_ROOT']
  • What is the best way to store multiple checkbox values in the database and work with it later on
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org