• 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

Wordpress add responsive srcset header image to theme

Override default Auth routes in Laravel 7

Laravel passport auth token not working after moving to different server

php 7 php.ini upload_max_filesize not working

how can I set a session variable in Drupal 8 and get it in a php script?

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

How do I truncate a decimal in PHP?

Search for array row with specific column value and return another value from qualifying row

Check if user online laravel

PHP to search within txt file and echo the whole line

How do I do HTTP basic authentication using Guzzle?

Select option from dropdown menu with PHP and mySql

Not able to access model in the controller mautic

Edit product hook WooCommerce

Laravel - Implicit route model binding with soft deleted data

About Contact Privacy policy Terms and conditions