• 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

Failing validation doesn't stop code execution in livewire component

Store / Website Column in Magento 2 Admin Grid - Custom Module

html-php form submission after validation through JavaScript [closed]

Laravel : How to Create Dropdown to Select FOREIGN KEY from Other Table?

How to show selected value using javascript in laravel

PHP function Not Working As Expected From functions.php Include File

Can't call javascript alert alertify library from PHP

Results page in other window

Open a popup box after receiving result from ajax

Laravel multi auth - Authentication user provider [] is not defined

Sentry on Symfony: how to exclude `NotFoundHttpException`

how to hide previous markers when new markers added in google map javascript api

How to find phpcs current default standard

Adding reCAPTCHA v2 into my PHP file

CodeIgniter force_download is not working

About Contact Privacy policy Terms and conditions