• 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

Live search query using JS and PHP for QA forum

500 Internal Server Error on Ajax request. Not sure the origin of the problem

php mysql + create a friend request system

Hide email address with stars (*)

PHP 8 - libxml_disable_entity_loader() has been deprecated. How do I replace the functionality it provides?

Required field only if another field has a value, must be empty otherwise

WooCommerce Additional Information - if empty, hide

Cache clear probem in Larave

Why does using salted hash on python and php give me different results?

Mysqli Output to a table

Add bold text and line break into Laravel Notification Email

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Check if user online laravel

How to identify whether webp image is static or animated?

how to insert data into select2 search input after scan using qrcode

About Contact Privacy policy Terms and conditions