• 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 make Canonicals with PHP

PHP Imap , php 7.4.3 on mac osx catalina

Laravel MSSQL Server Connection not working

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

Unable to Edit config.inc.php

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

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Passing a boolean value from checkbox in Laravel form

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

Laravel PackageManifest.php: Undefined index: name

PHP function Not Working As Expected From functions.php Include File

SQL AVG() to 2 decimals

Not able to override collapsible.js in magento 2

How do I set the maximum php memory limit

Refresh specific HTML content that retrieves data from MySQL

About Contact Privacy policy Terms and conditions