• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

Laravel Livewire: jQuery not working in child component loaded via @if statement

No definition found for function in vendor vscode

dompdf and img tag, image wont show

Unable to create lockable file - Laravel 8 & PHP 8

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

Dynamic dropdown Ajax PHP request

Fatal error: Trait 'LaminasDbAdapterLaminasDbAdapterAdapterInterface' not found in /var/www/vendor/laminas/laminas-db/src/Adapter/Adapter.php

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

How to fix Call to undefined method AppModelsTableName::factory?

How to get AJAX to post on second page?

How can i call a function that executes an fpdf based on the choice of a form selector?

laravel MVC execution flow

How to send parameters in soap request in php in __soapcall() function

Toggle between a textbox and a select using PHP

How can I make this nested location configuration use the correct path to call a php program?

About Contact Privacy policy Terms and conditions