• 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

Change the alert text on add to cart action without selected variation in Woocommerce

Woocommerce redirect after add-to-cart error

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

Laravel 5 issue with wherePivot

What will the best solution for this multiple optional filter?

Laravel Sanctum CSRF not authenticating

How to redirect to another page and call a Function there on Angular ng-click

Select option from dropdown menu with PHP and mySql

nginx err_connection_refused, can anyone help me?

Prevent blank space in pdf pages (DomPdf)

Smarty if isset

Make Calculator - When Button clicked the No shows in Textbox.

Open a popup box after receiving result from ajax

How to install PHP composer inside a docker container

Populate Dynamic Dropdowns List in Codeigniter

About Contact Privacy policy Terms and conditions