• 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

Log a user out of a website when they put their computer to sleep

301 Redirect to remove query string on homepage only

How to show selected value using javascript in laravel

Install mysql client in docker image

Show Custom Data in Woocommerce Order Details Admin Area

Convert date and time to Jalali in Laravel

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

How to create custom authentication in laravel 8?

Query Optimization, changing the queries in the loop into a single processing query

Using Associative arrays

Class AppHttpControllersUserController Does Not Exist

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

What is PHP's equivalent of JavaScript's "array.every()"?

Using spatie/media-library, how to rename a collection of uploaded files?

Laravel 5 session not persisting after user is logged in

About Contact Privacy policy Terms and conditions