Click here to Skip to main content
15,851,335 members
Home / Discussions / Web Development

Web Development

AnswerRe: HI can someone help me with my responsive gallery project? Pin
Member 1529865622-Jul-21 22:56
Member 1529865622-Jul-21 22:56 
QuestionHello, i need some help for a project with css and html Pin
Florina Catalina10-Mar-21 5:38
Florina Catalina10-Mar-21 5:38 
QuestionHelp me remove unused CSS Pin
maithu7029-Mar-21 2:27
maithu7029-Mar-21 2:27 
AnswerRe: Help me remove unused CSS Pin
Richard Deeming9-Mar-21 23:20
mveRichard Deeming9-Mar-21 23:20 
AnswerRe: Help me remove unused CSS Pin
User 1407655214-Jul-21 11:03
User 1407655214-Jul-21 11:03 
QuestionDeployments Pin
#realJSOP27-Feb-21 5:57
mve#realJSOP27-Feb-21 5:57 
QuestionASP.Net Web API Controller Question Pin
Kevin Marois26-Feb-21 8:47
professionalKevin Marois26-Feb-21 8:47 
QuestionPHP7+, working with datetime stored in cookie with json format Pin
jkirkerx17-Feb-21 12:48
professionaljkirkerx17-Feb-21 12:48 
I probably just chose the wrong format to store the datetime in the cookie, but it's worth pursuing time someone tells me to change it.

I need help with converting the date, so I can do a compare or diff, or perhaps dumping the date for something else, or just general help with making this work. Help can just be an idea or nudge. Keep in mind that I'm not a PHP 7 expert, and lost my knowledge of PHP back in 2005 or so. I've been working on this for hours and I'm not sure whether to dump it and start again, or do even more research.
public static function setJsonAuthCookie($userName, $userType): void {

        $today = new DateTime();

        $jsonData = array(
            "userName" => $userName,
            "userType" => $userType,
            "createdOn" => $today,
            "expires" => $today->add(new DateInterval('PT4H')),
            "token" => "",
            "auth0" => ""

        $jsonEncode = json_encode($jsonData, JSON_FORCE_OBJECT);
        setcookie("authJson", $jsonEncode, time()+240);


    public static function validateUser(): array {

        $cookie = clsAuth::getJsonAuthCookie();
        if (!isset($cookie)) {

            $formAction = "/pcad/unauthorized.phtml";
            header("Location: http://".$_SERVER['HTTP_HOST']."$formAction");

        } else {

            $userName = $cookie['userName'];
            $userType = $cookie['userType'];
            $createdOn = $cookie['createdOn'];
            $expires = $cookie['expires'];
            $token = $cookie['token'];
            $auth0 = $cookie['auth0'];

            // Convert the string date back into a date object
            $today = new DateTime();
            $dateString = $expires['date'];
            $timeZone = $expires['timezone'];

            echo "<div>validating token</div>";

            if ($dateString > $today) {

                echo "<div>token declined</div>";

                $formAction = "/pcad/";
                // header("Location: http://".$_SERVER['HTTP_HOST']."$formAction");

            } else {

                echo "<div>token accepted</div>";

// Cookie Value

Then reading the cookie, extracting the json, and trying to compare the date "expires" to $today which is DateTime
Tried to convert the string date in the JSON back to an PHP DateTime object, so I can say is today > expires
I tried for hours, using getDate, strtotime, and reading up on time in seconds since the epoch.
If it ain't broke don't fix it
Discover my world at

QuestionMessage Closed Pin
14-Feb-21 11:11
ellaluceero14-Feb-21 11:11 
AnswerRe: How To create a table in MS Access contain more than 255 filed ? Pin
Richard Deeming14-Feb-21 23:05
mveRichard Deeming14-Feb-21 23:05 
QuestionBootstrap - How do I make an icon a href link Pin
Jim McElhiney10-Feb-21 16:33
Jim McElhiney10-Feb-21 16:33 
AnswerRe: Bootstrap - How do I make an icon a href link Pin
Peter_in_278012-Feb-21 14:58
professionalPeter_in_278012-Feb-21 14:58 
QuestionPHP V7.4.14, convert this database function, understanding mssql_fetch_field to sqlsrv_fetch Pin
jkirkerx10-Feb-21 10:36
professionaljkirkerx10-Feb-21 10:36 
AnswerRe: PHP V7.4.14, convert this database function, understanding mssql_fetch_field to sqlsrv_fetch Pin
jkirkerx12-Feb-21 14:14
professionaljkirkerx12-Feb-21 14:14 
Questionphp 7.4.14 convert smalldatetime to string for html display Pin
jkirkerx9-Feb-21 13:14
professionaljkirkerx9-Feb-21 13:14 
AnswerRe: php 7.4.14 convert smalldatetime to string for html display Pin
Richard Deeming9-Feb-21 23:00
mveRichard Deeming9-Feb-21 23:00 
GeneralRe: php 7.4.14 convert smalldatetime to string for html display Pin
jkirkerx10-Feb-21 6:19
professionaljkirkerx10-Feb-21 6:19 
GeneralRefresh a div with pjax Pin
Member 150664316-Feb-21 10:32
Member 150664316-Feb-21 10:32 
GeneralRe: Refresh a div with pjax Pin
OriginalGriff6-Feb-21 10:45
mveOriginalGriff6-Feb-21 10:45 
Question500 Error Pin
#realJSOP4-Feb-21 6:49
mve#realJSOP4-Feb-21 6:49 
AnswerRe: 500 Error Pin
Richard Deeming4-Feb-21 6:59
mveRichard Deeming4-Feb-21 6:59 
GeneralRe: 500 Error Pin
#realJSOP4-Feb-21 8:33
mve#realJSOP4-Feb-21 8:33 
GeneralRe: 500 Error Pin
Richard Deeming4-Feb-21 22:42
mveRichard Deeming4-Feb-21 22:42 
GeneralRe: 500 Error Pin
#realJSOP7-Feb-21 10:08
mve#realJSOP7-Feb-21 10:08 
QuestionVS code/Live Server Browser issue Pin
ISHYY4-Feb-21 5:42
ISHYY4-Feb-21 5:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.