• 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 redirect to another page after n seconds in wordpress without using javascript?

WordPress - Dynamically add user ID to the end of a URL

Don't show recurring price for WooCommerce subscriptions worth 0$

Pages are working fine on localhost but not running on the hosting server

Add record for each array elements if missing in table

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

how to fix Service provider class not found when using repository?

possible options to create pdf file using html elements to generate invoice in php and codeigniter

Laravel 5.2: Unable to locate factory with name [default]

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

PHP: remove filename from path

Sum column values from multiple arrays

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

I want to display a sweetalert after the inserting of data in my database

Execute only one time and then wait set period of time before executing again

About Contact Privacy policy Terms and conditions