• 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 - Dynamically add user ID to the end of a URL

Laravel unique validation on multiple columns

Put content of wordpress page inside div

PHP Fatal error: Class not found - PHPUnit

Fatal error: [] operator not supported for strings

How to get quarter for future date using Carbon?

Last order would be re-order in wooCommerce. How is it possible?

Limit of log line written to Apache Errorlog from mod php error_log

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

What is the difference between client-side and server-side programming?

jQuery Ajax Post with data

Update Order custom Field value with WooCommerce REST API

Lumen - Postgresql setup - Composer

MongoDB Duplicate Documents even after adding unique key

XML to CSV with PHP converter [problem with images grabing]

About Contact Privacy policy Terms and conditions