Laravel - Problem Of How To Tune Strange Behavior With Sending Text Message

novice

I have a very special problem and I don't know how to deal with it.

I have web App in Laravel, when i open index page, I receive text message to my mobile phone. Problem is, sometimes I receive 2 messages or 3, sometimes 1. Is there a tool how to debug this strange behavior which is not always the same?

A few words about my code: user opens the page, and because its first visit Session doesn't have attribute message_sent and SendTextMessage::SendMessage($phoneNumber, $id_message, $smsCode, $newDateFormat); is executed. After that Session has message_sent and can't be sent again, for example if I refresh the page.

SendTextMessage::SendMessage() is Class in Laravel Helpers.

controller code:

public function index($url_attribute, $id_message, Request $request)
{      
    if(!Session::has('message_sent'))
    {
        $user = User::where('id_message', $id_message)->first()->toArray();
        $phoneNumber = $user['mobile_phone'];
        $smsCode = $user['sms_code'];
        $newDateFormat = date("d.m.yy", strtotime($smsExpirationTime));

        $request->session()->flash('message', 'Text message sended.' );

        SendTextMessage::SendMessage($phoneNumber,$id_message, $smsCode, $newDateFormat);
        Session::put('message_sent', true);

    }

    return view('login');
    
}

SendTextMessage Class:

class SendTextMessage 
{
    public static function SendMessage($phoneNumber, $id_message, $smsCode, $newDateFormat)
    {
        $sms = new Connect();
        $sms->Create("user","pass",Connect::AUTH_PLAIN);
        $sms->Send_SMS($phoneNumber,"Message");
        $sms->Logout();
    }
}

Many thanks for any tip or help.

UPDATE:

problem is only in Chrome. Edge and internet explorer are fine.

JBA

You should maybe try to change the way you use Laravel Session. You indicated that it was working fine on some browsers, that means your server-side code is correct so far, but there is someting messing with Chrome… From there, if you take a quick look at the Laravel Session doc, you'll see that Session can be stored in cookies, and I bet that this is your actual setup (check in your .env file the SESSION_DRIVER constant, or in your config/session.php file).

If so, to confirm that this cookies-based session setting is the culprit, you might want to change the Session config to make it browser-independent: any other option than cookies will work, the database or file options might be the easier to setup… And if it works I would strongly encourage you to keep using this no-cookie setting to make your code browser-safe.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Laravel Auth strange behavior

Strange behavior in Laravel

Laravel route strange behavior

Strange behavior with BIGINT in Laravel or PHP

Strange behaviour while sending broadcast message

Having problem with message sending command

How to use realloc (strange behavior)

Display text in textfield has a strange behavior

Xpath strange behavior - not matching text nodes

Strange Behavior When Pasting Text in UITextField

Strange text-mode file output behavior

Strange behavior laravel 6.2 collections on php 7.4

Strange behavior on laravel many to many relationship

Problem with "/" laravel message validation

Mandrill problem with sending emails: Message not sent: queued

How to fix strange behavior of Auth::loginUsingId() when I set remember me argument to true in laravel

TEdit and WM_PAINT message handler strange behavior

Authorization when sending a text message using AmazonSNSClient

Sending text message to phone using twilio

Sending url via smtplib module (text message)

uWebsocket sending messages via WebSocket outside of the .message Behavior context

sending error message laravel required inputs

How to correct strange behavior in Pandas styled dataframe

How strange the textinput method behavior in jquery mobile

Problem sending text to stdin of running process

How to show message in Popup without reloading the page in Laravel? I am sending data using CURL

Problem with helper function and sending variable with redirect in Laravel

Laravel Query Sending Different Result For Same Problem

Laravel 5.7: How can I translate the text of reset password message

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive