• 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

How to loop a tree array with unknown depth and get array blocks?

How to set dynamic `home` and `siteurl` in WordPress?

What is the function of the (new Date()).getTime() in PHP?

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Sentry on Symfony: how to exclude `NotFoundHttpException`

add_action() function in wordpress not working [duplicate]

Install mysql client in docker image

Encrypt in php and decrypt in Dart(flutter)

Laravel Jetsream Profile page not loading on fresh install

I need to link Google Sheet with my Laravel

How can I get new CSRF token in LARAVEL by using ajax

Comma separated list from array with "and" before last element

how to youtube api data to print in toolset metabox using a button click before save-post

Adding reCAPTCHA v2 into my PHP file

About Contact Privacy policy Terms and conditions